Skip to content

Commit

Permalink
Bug 3132: run ansible-pull from the right dir, with HOME set
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jan 1, 2015
1 parent 99a3a2d commit 18074d8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion localhost
@@ -1 +1 @@
localhost
localhost ansible_python_interpreter=/usr/local/bin/python2.7
11 changes: 10 additions & 1 deletion roles/base/tasks/ansible-pull.yml
Expand Up @@ -29,11 +29,20 @@
version: master
accept_hostkey: yes

- name: install ansible-pull cronscript
tags: ansible-pull
template:
src: "run-ansible-pull.sh.j2"
dest: "/home/{{ service_account }}/run-ansible-pull.sh"
mode: 0755
owner: "{{ service_account }}"
group: wheel

- name: install ansible-pull crontask
tags: ansible-pull
cron:
name: ansible-pull
job: "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/bbinfra/bin ansible-pull -C master -d /home/{{ service_account }}/repo/ -m git -U {{ ansible_git_repository }} -o -s 3600 -i localhost --vault-password-file=/home/{{ service_account }}/.vault-password local.yml"
job: "/home/{{ service_account }}/run-ansible-pull.sh"
user: "{{ service_account }}"
minute: 0
state: "{{ 'absent' if no_ansible_pull|default('false')|bool else 'present' }}"
Expand Down
18 changes: 18 additions & 0 deletions roles/base/templates/run-ansible-pull.sh.j2
@@ -0,0 +1,18 @@
#! /bin/sh

# set some environment variables that ansible-pull needs
export HOME=/home/{{ service_account }}
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/home/{{ service_account }}/bin

# run ansible-pull from the directory containing the repository (and, thus, the inventory file)
cd /home/{{ service_account}}/repo
ansible-pull \
-C master \
-d /home/{{ service_account }}/repo/ \
-m git \
-U {{ ansible_git_repository }} \
-o \
-s 3600 \
-i localhost \
--vault-password-file=/home/{{ service_account }}/.vault-password \
local.yml

0 comments on commit 18074d8

Please sign in to comment.