Skip to content

Commit

Permalink
Initial commit, ansible and debdev.
Browse files Browse the repository at this point in the history
  • Loading branch information
rektide committed Nov 11, 2012
0 parents commit 2b217d3
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ansible.pb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- hosts: all
user: rektide
vars_files:
- "vars/ansible.vars"
tasks:
- include: "tasks/xdg.vars.tasks"
- include: "tasks/ansible.tasks"
5 changes: 5 additions & 0 deletions debdev.pb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: all
sudo: true
tasks:
- include: "tasks/debdev.tasks"
6 changes: 6 additions & 0 deletions files/ansible/env.ansible
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export ANSIBLE_HOSTS={{ANSIBLE_HOSTS_FILE}}
source {{INSTALL_DIR}}/hacking/env-setup
if [[ -e {{CONFIG_DIR}}/ansible.rc ]]
then
source {{CONFIG_DIR}}/ansible.rc
fi
1 change: 1 addition & 0 deletions files/ansible/hosts.localhost
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
127.0.0.1
7 changes: 7 additions & 0 deletions files/ansible/manual.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

mkdir -p ~/.local/opt ~/.local/bin ~/.config/ansible
[[ ! -d ~/.local/opt/ansible ]] && git clone https://github.com/ansible/ansible.git ~/.local/opt/ansible
[[ ! -e ~/.ansible/hosts.localhost ]] && echo 127.0.0.1 >> ~/.ansible/hosts.localhost
[[ ! -e ~/.ansible/hosts ]] && ln -s ~/.ansible/hosts.localhost ~/.ansible/hosts
[[ ! -e ~/.ansible/env.ansible ]] && cp env.ansible ~/.ansible/env.ansible
41 changes: 41 additions & 0 deletions tasks/ansible.tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- name: insure CONFIG_DIR:$CONFIG_DIR exists
file: path=$CONFIG_DIR state=directory
- name: insure INSTALL_DIR:$INSTALL_DIR exists
file: path=$INSTALL_DIR state=directory
#### default hosts file
- name: copy DEFAULT_HOSTS:$DEFAULT_HOSTS into CONFIG_DIR:$CONFIG_DIR
copy: src=files/ansible/$DEFAULT_HOSTS dest=$CONFIG_DIR/
- name: check for existing ANSIBLE_HOSTS_FILE:$ANSIBLE_HOSTS_FILE
shell: test -e $ANSIBLE_HOSTS_FILE && echo 1 || echo 0
register: has_ansible_hosts_file
- name: default symlink ANSIBLE_HOSTS_FILE:$ANSIBLE_HOSTS_FILE to DEFAULT_HOSTS:$DEFAULT_HOSTS
file: src=$CONFIG_DIR/$DEFAULT_HOSTS dest=$ANSIBLE_HOSTS_FILE state=link
when_integer: ${has_ansible_hosts_file.stdout} == 0
#### env setter helper
- name: check for existing CONFIG_DIR/ANSIBLE_ENV:$CONFIG_DIR/$ANSIBLE_ENV
shell: test -e $CONFIG_DIR/$ANSIBLE_ENV && echo 1 || echo 0
register: has_ansible_env
- name: template ANSIBLE_ENV:$ANSIBLE_ENV into CONFIG_DIR:$CONFIG_DIR
template: src=files/ansible/$ANSIBLE_ENV dest=$CONFIG_DIR/$ANSIBLE_ENV
when_integer: ${has_ansible_env.stdout} == 0
#### link to install
- name: check for existing CONFIG_DIR/INSTALL_LINK:$CONFIG_DIR/$INSTALL_LINK install link
shell: test -e $CONFIG_DIR/$INSTALL_LINK && echo 0 || echo 1
register: need_install_link
- name: creating install link CONFIG_DIR/INSTALL_LINK:$CONFIG_DIR/$INSTALL_LINK to $INSTALL_DIR
file: src=$INSTALL_DIR dest=$CONFIG_DIR/$INSTALL_LINK state=link
when_integer: ${need_install_link.stdout} > 0 and ${has_xdg_config_dir.stdout} > 0
#### xdg_config_dir/ansible install
- name: check whether xdg_config_dir exists qand is different from CONFIG_DIR:$CONFIG_DIR
shell: test "${has_xdg_config_dir.stdout}" == 1 -a "x${xdg_config_dir.stdout}" != "x$CONFIG_DIR" -a ! -e "${xdg_config_dir.stdout}/ansible" && echo 1 || echo 0
register: need_config_link
- name: create xdg_config_dir:${xdg_config_dir.stdout} link to $CONFIG_DIR
file: src=$CONFIG_DIR dest=${xdg_config_dir.stdout}/ansible state=link
when_integer: ${need_config_link.stdout} > 0
### install git
- name: git clone ansible repo
git: repo=$ANSIBLE_GIT dest=$INSTALL_DIR
- name: apt-get install ansible dependencies
apt: pkg=$DEPS state=latest

3 changes: 3 additions & 0 deletions tasks/debdev.tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: mini-dinstall, debrelease, dput deps
apt: pkg=mini-dinstall,dput,pbuilder,devscripts,fakeroot state=latest
7 changes: 7 additions & 0 deletions tasks/xdg.vars.tasks
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: get xdg_config_dir
shell: echo ${XDG_CONFIG_HOME:-~/.config}
register: xdg_config_dir
- name: test xdg_config_dir
shell: test -d $xdg_config_dir && echo 1 || echo 0
register: has_xdg_config_dir
10 changes: 10 additions & 0 deletions vars/ansible.vars
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
DEPS: python-jinja2,python-yaml,python-paramiko,python-apt
ANSIBLE_GIT: https://github.com/ansible/ansible.git
INSTALL_DIR: ~/.local/opt/ansible
CONFIG_DIR: ~/.ansible
BIN_DIR: ~/.local/bin/
ANSIBLE_HOSTS_FILE: $CONFIG_DIR/hosts
DEFAULT_HOSTS: hosts.localhost
ANSIBLE_ENV: env.ansible
INSTALL_LINK: lib

0 comments on commit 2b217d3

Please sign in to comment.