-
Notifications
You must be signed in to change notification settings - Fork 3
/
deployer_bastion.yml
122 lines (108 loc) · 2.94 KB
/
deployer_bastion.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
---
# Deploy the VM
- name: YUM Nutanix Deployer
hosts: localhost
gather_facts: false
tasks:
- name: Provision YUM Repository on Nutanix
include_role:
name: nutanix_provisioner
vars:
vm_defs: "{{ vm_defs_bastion }}"
tags:
- provision
- name: Refresh inventory after provisioning
meta: refresh_inventory
# Deploy ansible private key to VM
- name: Ansible private key
hosts: bastion
remote_user: ansible
become: yes
tasks:
- name: Deploy private key to server
copy:
content: "{{ ansible_ssh_private_key }}"
dest: /home/ansible/.ssh/id_rsa
owner: ansible
group: ansible
mode: 0600
- name: Install ntpd
yum:
name: "ntp"
state: "latest"
- name: Configure ntp server
template:
src: "ntp.conf.j2"
dest: "/etc/ntp.conf"
- name: Disable chrony
service:
name: "chronyd"
state: stopped
enabled: false
- name: Start/enable ntpd
service:
name: "ntpd"
state: started
enabled: true
# Configure the VM
- name: YUM Nutanix Configuration
hosts: bastion
remote_user: ansible
become: yes
vars_prompt:
- name: "rhsm_username"
prompt: "RHSM Username"
- name: "rhsm_password"
prompt: "RHSM Password"
vars:
repo_list:
- "rhel-7-server-rpms"
- "rhel-7-server-ose-3.9-rpms"
- "rhel-7-fast-datapath-rpms"
- "rhel-7-server-ansible-2.5-rpms"
- "rh-gluster-3-client-for-rhel-7-server-rpms"
base_packages:
- yum-utils
- git
- ansible
git_repo_remote: "https://github.com/mbach04/nutanix_automation_testing.git"
git_repo_local: "/home/ansible/nutanix_automation"
git_repo_version: "integration"
tasks:
- name: Remove self-referencing yum repos defined from cloud-init
yum_repository:
name: "{{ item }}"
state: absent
enabled: no
loop: "{{ vm_yum_repos | map(attribute='reponame') | list }}"
- name: Import GPG Key
shell: rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
args:
warn: no
- name: Register with subscription-manager
redhat_subscription:
state: present
username: "{{ rhsm_username }}"
password: "{{ rhsm_password }}"
autosubscribe: yes
- name: Disable all repositories
shell: "subscription-manager repos --disable='*'"
- name: Enable repositories
shell: "subscription-manager repos --enable={{ item }}"
loop: "{{ repo_list }}"
- name: Get latest YUM updates
yum:
name: '*'
state: latest
- name: Install Packages
yum:
name: "{{ base_packages }}"
state: installed
- name: Pull Git repository
git:
repo: "{{ git_repo_remote }}"
dest: "{{ git_repo_local }}"
version: "{{ git_repo_version }}"
become: no
tags:
- git