2013-01-24 16:29:50 +00:00
|
|
|
# ansible-pull setup
|
2012-05-02 03:22:23 +00:00
|
|
|
#
|
|
|
|
# on remote hosts, set up ansible to run periodically using the latest code
|
|
|
|
# from a particular checkout, in pull based fashion, inverting Ansible's
|
2012-08-07 00:00:31 +00:00
|
|
|
# usual push-based operating mode.
|
2012-05-02 03:22:23 +00:00
|
|
|
#
|
|
|
|
# This particular pull based mode is ideal for:
|
|
|
|
#
|
|
|
|
# (A) massive scale out
|
|
|
|
# (B) continual system remediation
|
|
|
|
#
|
|
|
|
# DO NOT RUN THIS AGAINST YOUR HOSTS WITHOUT CHANGING THE repo_url
|
2012-05-02 03:25:19 +00:00
|
|
|
# TO SOMETHING YOU HAVE PERSONALLY VERIFIED
|
|
|
|
#
|
2012-08-07 00:00:31 +00:00
|
|
|
#
|
2012-04-30 21:24:58 +00:00
|
|
|
---
|
2012-05-02 03:25:19 +00:00
|
|
|
|
|
|
|
- hosts: pull_mode_hosts
|
2012-04-30 21:24:58 +00:00
|
|
|
user: root
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-04-30 21:24:58 +00:00
|
|
|
vars:
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-09-14 18:01:44 +00:00
|
|
|
# schedule is fed directly to cron
|
2012-04-30 21:24:58 +00:00
|
|
|
schedule: '*/15 * * * *'
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-04-30 21:24:58 +00:00
|
|
|
# User to run ansible-pull as from cron
|
|
|
|
cron_user: root
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-09-14 18:01:44 +00:00
|
|
|
# File that ansible will use for logs
|
|
|
|
logfile: /var/log/ansible-pull.log
|
|
|
|
|
2012-04-30 21:24:58 +00:00
|
|
|
# Directory to where repository will be cloned
|
|
|
|
workdir: /var/lib/ansible/local
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-05-02 03:25:19 +00:00
|
|
|
# Repository to check out -- YOU MUST CHANGE THIS
|
|
|
|
# repo must contain a local.yml file at top level
|
2012-05-02 03:22:23 +00:00
|
|
|
#repo_url: git://github.com/sfromm/ansible-playbooks.git
|
2012-05-02 03:25:19 +00:00
|
|
|
repo_url: SUPPLY_YOUR_OWN_GIT_URL_HERE
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-04-30 21:24:58 +00:00
|
|
|
tasks:
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-04-30 21:24:58 +00:00
|
|
|
- name: Install ansible
|
|
|
|
action: yum pkg=ansible state=installed
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-04-30 21:24:58 +00:00
|
|
|
- name: Create local directory to work from
|
|
|
|
action: file path=$workdir state=directory owner=root group=root mode=0751
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-05-02 05:49:17 +00:00
|
|
|
- name: Copy ansible inventory file to client
|
|
|
|
action: copy src=/etc/ansible/hosts dest=/etc/ansible/hosts
|
|
|
|
owner=root group=root mode=0644
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-04-30 21:24:58 +00:00
|
|
|
- name: Create crontab entry to clone/pull git repository
|
2012-09-14 18:01:44 +00:00
|
|
|
action: template src=templates/etc_cron.d_ansible-pull.j2 dest=/etc/cron.d/ansible-pull owner=root group=root mode=0644
|
2012-05-02 03:22:23 +00:00
|
|
|
|
2012-09-14 18:01:44 +00:00
|
|
|
- name: Create logrotate entry for ansible-pull.log
|
2012-09-19 01:10:07 +00:00
|
|
|
action: template src=templates/etc_logrotate.d_ansible-pull.j2 dest=/etc/logrotate.d/ansible-pull owner=root group=root mode=0644
|