Repurpose old ansiblehost role

It's now an automatic pullinator
This commit is contained in:
Salt 2020-02-06 00:32:31 -06:00
parent 9cf24c1acc
commit 129cc13848

View File

@ -1,7 +1,8 @@
#!/usr/bin/ansible-playbook #!/usr/bin/ansible-playbook
# vim:ft=ansible: # vim:ft=ansible:
--- ---
- name: Install Ansible-required packages via apt - name: Set up system for Ansible
- name: Install Ansible-required packages via apt
apt: apt:
name: "{{ packages }}" name: "{{ packages }}"
vars: vars:
@ -10,45 +11,35 @@
- python3-boto - python3-boto
- python3-boto3 - python3-boto3
- python3-botocore - python3-botocore
become: true - name: Install Ansible-required packages via pip
- name: Install Ansible-required packages via pip
pip: pip:
name: "{{ packages }}" name: "{{ packages }}"
state: latest state: latest
vars: vars:
packages: packages:
- ansible - ansible
become: true - name: Create .aws directory for root
- name: Create .aws directory for salt
file: file:
path: ~/.aws path: ~/.aws
state: directory state: directory
become: true - name: Copy AWS credentials
become_user: salt
- name: Copy AWS credentials
copy: copy:
src: "{{ role_path }}/files/awscredentials" src: awscredentials
dest: ~/.aws/credentials dest: ~/.aws/credentials
mode: 0600 mode: 0600
become: true - name: Copy Ansible private key
become_user: salt
- name: Copy Ansible private key
copy: copy:
src: "{{ role_path }}/files/ansiblekey" src: ansiblekey
dest: ~/.ssh/ansible dest: ~/.ssh/ansible
mode: 0600 mode: 0600
become: true - name: Create system copy of Ansible repo
become_user: salt
- name: Create Projects directory for salt
file:
path: ~/Projects
state: directory
become: true
become_user: salt
- name: Clone Ansible repository
git: git:
force: true force: true
repo: https://gitlab.com/rehashedsalt/ansible repo: https://gitlab.com/rehashedsalt/ansible
dest: ~/Projects/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"
become: true become: true
become_user: salt