-
Notifications
You must be signed in to change notification settings - Fork 4
/
provision.yml
123 lines (110 loc) · 3.06 KB
/
provision.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
---
- hosts: localhost
tasks:
- name: Deploy
include_role:
name: aws_deploy
- name: wait for all nodes to have SSH reachability
hosts: "control_nodes"
become: true
gather_facts: false
tasks:
- include_role:
name: ansible.workshops.connectivity_test
- name: create inventory file on control1
hosts: "*control1*"
become: true
vars:
foo: []
tasks:
- dnf: name=python3-pip state=present
- name: Install ansible on control node
pip:
name: ansible
- name: Create ansible user and download tar
hosts: "*control1*"
vars:
inventory_list: []
tasks:
- name: Check if inventory file exists
stat:
path: "~/inventory"
register: file_data
- name: Delete if file exists
file:
path: "~/inventory"
state: absent
when: file_data.stat.exists
- name: Create inventory list
set_fact:
inventory_list: "{{ inventory_list + [hostvars[item]['private_ip']] }}"
with_items:
- "{{ groups['all'] }}"
- lineinfile:
dest: "~/inventory"
line: "{{ item }}"
create: yes
with_items: "{{ inventory_list }}"
- name: Copy create ansible playbook on main controller
copy:
src: "playbooks/create_ansible.yml"
dest: "~/create_ansible.yml"
- name: copy private key file
copy:
src: "{{ playbook_dir }}/{{ec2_name_prefix}}/{{ec2_name_prefix}}-private.pem"
dest: "~/private-key.pem"
mode: 0600
- name: Run ansible command
command:
cmd: ansible-playbook -i inventory create_ansible.yml
- name: download AAP
include_role:
name: ansible.workshops.aap_download
- name: Become root and install AAP
hosts: "*control1*"
become: true
vars:
user: ansible
aap_dir: "/home/{{ user }}/aap_install"
tasks:
- name: Copy aap.tar.gz to ansible user home
copy:
src: "aap.tar.gz"
dest: "/home/ansible/"
- name: Create directory for automation controller
file:
path: "{{ aap_dir }}"
state: directory
- name: Extract tarball
unarchive:
remote_src: yes
src: "/home/ansible/aap.tar.gz"
dest: "{{ aap_dir }}"
extra_opts: ['--strip-components=1', '--show-stored-names']
- name: Set AAP local repository on controller node
include_role:
name: ansible.workshops.aap_repo
- name: template inventory file
template:
src: "templates/inventory.j2"
dest: "{{ aap_dir }}/inventory"
- name: Become ansible user and run installer
hosts: "*control1*"
become_user: ansible
become: true
vars:
user: ansible
aap_dir: "/home/{{ user }}/aap_install"
tasks:
- name: run the Automation Controller installer
command: "sudo ./setup.sh -e gpgcheck=0"
args:
chdir: "{{ aap_dir }}"
async: 1400
poll: 15
- name: Show Details of controller node
debug:
msg: "IP address of controller is {{ hostvars[item]['ansible_host'] }}"
with_items: "{{ groups['control_nodes'] }}"
tags:
- setup