2019-09-15 00:39:47 -05:00
|
|
|
#!/usr/bin/ansible-playbook
|
|
|
|
# vim:ft=ansible:
|
|
|
|
---
|
2020-02-06 00:32:31 -06:00
|
|
|
- name: Set up system for Ansible
|
2020-02-06 00:38:04 -06:00
|
|
|
block:
|
2020-02-06 00:32:31 -06:00
|
|
|
- name: Install Ansible-required packages via apt
|
|
|
|
apt:
|
|
|
|
name: "{{ packages }}"
|
|
|
|
vars:
|
|
|
|
packages:
|
2020-02-06 00:59:21 -06:00
|
|
|
- python3-pip
|
|
|
|
- python3-boto
|
|
|
|
- python3-boto3
|
|
|
|
- python3-botocore
|
|
|
|
- python3-setuptools
|
2020-02-06 00:43:43 -06:00
|
|
|
- python-pip
|
|
|
|
- python-boto
|
|
|
|
- python-boto3
|
|
|
|
- python-botocore
|
|
|
|
- python-setuptools
|
2020-02-06 00:32:31 -06:00
|
|
|
- name: Install Ansible-required packages via pip
|
|
|
|
pip:
|
|
|
|
name: "{{ packages }}"
|
|
|
|
state: latest
|
|
|
|
vars:
|
|
|
|
packages:
|
|
|
|
- ansible
|
|
|
|
- name: Create .aws directory for root
|
|
|
|
file:
|
|
|
|
path: ~/.aws
|
|
|
|
state: directory
|
|
|
|
- name: Copy AWS credentials
|
|
|
|
copy:
|
|
|
|
src: awscredentials
|
|
|
|
dest: ~/.aws/credentials
|
2020-02-06 01:01:18 -06:00
|
|
|
mode: "0600"
|
2020-02-06 00:32:31 -06:00
|
|
|
- name: Copy Ansible private key
|
|
|
|
copy:
|
|
|
|
src: ansiblekey
|
|
|
|
dest: ~/.ssh/ansible
|
2020-02-06 01:01:18 -06:00
|
|
|
mode: "0600"
|
2020-02-14 15:40:31 -06:00
|
|
|
- name: Copy Ansible password file
|
|
|
|
copy:
|
|
|
|
src: ansiblevaultpass
|
|
|
|
dest: /root/ansiblevaultpass
|
|
|
|
mode: "0600"
|
2020-02-06 00:32:31 -06:00
|
|
|
- name: Create system copy of Ansible repo
|
|
|
|
git:
|
|
|
|
force: true
|
|
|
|
repo: https://gitlab.com/rehashedsalt/ansible
|
|
|
|
dest: /opt/ansible-repo
|
|
|
|
- name: Set up pull and run cronjob
|
|
|
|
cron:
|
2020-02-11 14:43:25 -06:00
|
|
|
minute: "0"
|
|
|
|
hour: "*/12"
|
2020-02-06 00:32:31 -06:00
|
|
|
name: ansible-pull
|
2020-02-17 21:51:27 -06:00
|
|
|
job: "cd /opt/ansible-repo && HOME=/root /usr/local/bin/ansible-playbook ec2.yml --vault-password-file /root/ansiblevaultpass > /var/log/ansible-pull.log 2>&1"
|
2019-09-15 00:39:47 -05:00
|
|
|
become: true
|