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: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
|
|
|
|
mode: 0600
|
|
|
|
- name: Copy Ansible private key
|
|
|
|
copy:
|
|
|
|
src: ansiblekey
|
|
|
|
dest: ~/.ssh/ansible
|
|
|
|
mode: 0600
|
|
|
|
- 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:
|
|
|
|
hour: 0
|
|
|
|
name: ansible-pull
|
|
|
|
job: "cd /opt/ansible-repo && ansible-playbook ec2.yml"
|
2019-09-15 00:39:47 -05:00
|
|
|
become: true
|