-
Notifications
You must be signed in to change notification settings - Fork 2
/
gce-tower-ansible-create-instance-and-install-software.yml
86 lines (74 loc) · 1.95 KB
/
gce-tower-ansible-create-instance-and-install-software.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
---
- name: Create Instances in GCE
hosts: localhost
gather_facts: False
connection: local
tasks:
- name: Create an Instance based on image "{{image}}"
gce:
instance_names: "{{instance_names}}"
zone: "{{zone}}"
machine_type: "{{machine_type}}"
image: "{{image}}"
state: present
preemptible: true
disk_size: "{{disk_size}}"
tags: http-server,https-server,cockpit-console
register: gce
- name: Add disk to Instance
gce_pd:
delete_on_termination: yes
instance_name: "{{instance_names}}"
mode: READ_WRITE
name: vg-ocp
size_gb: 50
state: present
zone: "{{zone}}"
- name: Save host data within a Group
add_host:
hostname: "{{ item.public_ip }}"
groupname: gce_instances_temp
with_items: "{{ gce.instance_data }}"
- name: Wait for SSH to come up
wait_for: host={{ item.public_ip }} port=22 delay=10 timeout=60
with_items: "{{ gce.instance_data }}"
- name: setting fact
set_fact: host={{ item.public_ip }}
with_items: "{{ gce.instance_data }}"
- name: Configure Hosts post-creation
hosts: gce_instances_temp
gather_facts: True
remote_user: rcalvaga
become: yes
become_method: sudo
tasks:
- name: Install Cockpit Console
yum:
name: "{{ item }}"
state: latest
with_items:
- cockpit
- cockpit-dashboard
- name: Firewall Access Rules For Cockpit
command: firewall-cmd --add-port=9090/tcp
command: firewall-cmd --permanent --add-port=9090/tcp
- name: Start Cockpit Service
service:
name: cockpit.socket
state: started
enabled: yes
- name: install Apache
yum:
name: httpd
state: latest
- name: start Apache Service
service:
name: httpd
state: started
enabled: yes
- name: create ansible user
user:
name: ansible
comment: "Ansible Workshop"
password: $1$ctRQ8kmb$PMF.2YAjQrdjiDGFuE4uw0
group: wheel