forked from redhat-cop/rhis-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovisioner.yml
91 lines (74 loc) · 2.45 KB
/
provisioner.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
---
# These plays set up your provisioner node to run rhis_builder
- name: "Setup provisioner"
hosts: build_control
connection: local
gather_facts: true
tasks:
- name: "Create ssh keys"
community.crypto.openssh_keypair:
path: "~/.ssh/id_rsa"
size: "4096"
mode: 0600
- name: "Add the new key to authorize_keys"
ansible.posix.authorized_key:
user: "{{ ansible_user_id }}"
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
- name: "Ensure we can ssh"
ansible.builtin.shell: "ssh localhost 'whoami'"
changed_when: ansible_user_id in result.stdout
register: result
- name: "Setup root configuration"
hosts: build_control
become: true
connection: local
gather_facts: true
tasks:
- name: "Ensure python pip is installed"
ansible.builtin.dnf:
name: python3-pip
state: present
- name: "Install required python packages"
ansible.builtin.pip:
name:
- pyvmomi
- pyvim
- name: "Pull govc from github releases"
ansible.builtin.get_url:
url: "https://github.com/vmware/govmomi/releases/latest/download/govc_Linux_x86_64.tar.gz"
dest: /root/govc_Linux_x86_64.tar.gz
mode: '0700'
- name: "Unarchive the file"
ansible.builtin.unarchive:
src: /root/govc_Linux_x86_64.tar.gz
dest: /usr/bin
remote_src: true #because we are not root
- name: "Ensure that provisioner can resolve itself"
ansible.builtin.lineinfile:
path: /etc/hosts
search_string: "{{ ansible_default_ipv4.address }}"
line: "{{ ansible_default_ipv4.address }} {{ ansible_fqdn }}"
owner: root
group: root
mode: '0644'
- name: "Ensure we can reach the provisioner"
ansible.builtin.wait_for:
host: "{{ ansible_fqdn }}"
port: 22
timeout: 10
- name: "Include the vmware variables"
ansible.builtin.include_vars:
file: "init_env/vmware/group_vars/all/vmware_vars.yml"
- name: "Ensure that provisioner can resolve vcenter"
ansible.builtin.lineinfile:
path: /etc/hosts
search_string: "{{ vcenter_ip }}"
line: "{{ vcenter_ip }} {{ vcenter_hostname }}"
owner: root
group: root
mode: '0644'
- name: "Ensure we can reach the vcenter"
ansible.builtin.wait_for:
host: "{{ vcenter_hostname }}"
port: 443
timeout: 10