-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
143 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
# this vars file will be used by ansible-pull (where the host will always be 127.0.0.1) | ||
|
||
my_remote_user: admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
|
||
- name: run simple action (to be run by ansible pull on remote host) | ||
hosts: 127.0.0.1 | ||
remote_user: "{{ my_remote_user }}" | ||
become: no | ||
become_method: sudo | ||
become_user: root | ||
|
||
roles: | ||
- ansible_pull_action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
|
||
- name: set up simple ansible pull cron job | ||
hosts: primary | ||
remote_user: "{{ my_remote_user }}" | ||
become: no | ||
become_method: sudo | ||
become_user: root | ||
|
||
roles: | ||
- { role: admin_user, when: "'development' not in group_names" } | ||
- ansible_pull_setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
|
||
- name: print working directory | ||
command: pwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
|
||
- name: add ansible ppa | ||
apt_repository: | ||
repo: ppa:ansible/ansible | ||
become: yes | ||
|
||
- name: install git and ansible | ||
apt: | ||
name: "{{ item }}" | ||
update_cache: yes | ||
become: yes | ||
with_items: | ||
- git | ||
- ansible | ||
|
||
- name: create local dir to work from | ||
file: | ||
path: "{{ workdir }}" | ||
state: directory | ||
owner: "{{ my_remote_user }}" | ||
group: "{{ my_remote_user }}" | ||
mode: 0751 | ||
become: yes | ||
|
||
- name: create initial empty log file | ||
file: | ||
state: touch | ||
path: "{{ logfile }}" | ||
owner: "{{ my_remote_user }}" | ||
group: "{{ my_remote_user }}" | ||
mode: 0644 | ||
become: yes | ||
|
||
- name: Create crontab entry to ansible-pull | ||
cron: | ||
name: ansible-pull action | ||
user: "{{ my_remote_user }}" | ||
job: "ansible-pull --directory {{ workdir }} --url {{ repo_url }} --checkout {{ repo_branch }} --full --force -i '127.0.0.1,' playbooks/ansible-pull-action.yml >> {{ logfile }} 2>&1" | ||
|
||
- name: Create logrotate entry for ansible-pull.log | ||
template: | ||
src: etc_logrotate.d_ansible-pull.j2 | ||
dest: /etc/logrotate.d/ansible-pull | ||
owner: "{{ my_remote_user }}" | ||
group: "{{ my_remote_user }}" | ||
mode: 0644 | ||
become: yes |
7 changes: 7 additions & 0 deletions
7
roles/ansible_pull_setup/templates/etc_logrotate.d_ansible-pull.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{ logfile }} { | ||
rotate 7 | ||
daily | ||
compress | ||
missingok | ||
notifempty | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# File that ansible will use for logs | ||
logfile: /var/log/ansible-pull.log | ||
|
||
# Directory to where repository will be cloned | ||
workdir: /var/lib/ansible/local | ||
|
||
repo_url: git://github.com/discopatrick/ansible-pocs.git | ||
|
||
repo_branch: feature/ansible_pull |