blob: 765073745c5e4b6e1a424fab19e64b2145af4e02 (
plain)
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
124
125
126
127
128
129
130
131
132
133
|
---
- hosts: status_planned
gather_facts: no
vars:
token: "{{ nb_token }}"
vm_name: "{{ inventory_hostname }}"
tag_merged: []
debug_merged: []
vars_files:
- ../variables/deploy-variables.yml
pre_tasks:
- name: Check lock
wait_for:
path: "{{ lockfile }}"
state: absent
timeout: 600
msg: Lock did not disappear in time
delegate_to: localhost
- name: Create lock
file:
path: "{{ lockfile }}"
state: touch
delegate_to: localhost
tasks:
- name: Pipeline
block:
- name: Gather details
block:
- import_tasks: "../tasks/netbox_query_vm.yml"
- import_tasks: "../tasks/netbox_query_cluster.yml"
no_log: true
- name: Assign variables
block:
- import_tasks: "../tasks/netbox_evaluate_cluster.yml"
- import_tasks: "../tasks/netbox_evaluate_vm.yml"
- name: Verify compliance
block:
- name: Check status
fail:
msg: The object is not Planned.
when: status != 'planned'
- name: Check tag
fail:
msg: The object is marked as already being in deployment.
when: '"active-deployment" in tags'
- name: Check platform
fail:
msg: The object does not contain a valid platform attribute.
when: os != 'openSUSE-Leap-x86_64' #support more OS's later
- name: Write tag and journal
import_tasks: "../tasks/netbox_tags_pre.yml"
- name: Gather site configuration
block:
- import_tasks: "../tasks/netbox_query_site.yml"
- import_tasks: "../tasks/netbox_evaluate_site.yml"
no_log: true
- name: Gather prefix
block:
- import_tasks: "../tasks/netbox_query_prefix.yml"
- import_tasks: "../tasks/netbox_evaluate_prefix.yml"
no_log: true
- name: Gather IP address
block:
- import_tasks: "../tasks/netbox_query_ip.yml"
- import_tasks: "../tasks/netbox_evaluate_ip.yml"
no_log: true
- name: Provision virtual machine
import_tasks: "../tasks/configure_libvirt.yml"
- name: Configure DHCP
import_tasks: "../tasks/init_dhcp.yml"
- name: Configure DNS
import_tasks: "../tasks/init_dns.yml"
- name: Configure Deployment Servers
import_tasks: "../tasks/init_dps.yml"
- name: Create interface object in NetBox or use existing one
block:
- import_tasks: "../tasks/netbox_init_interface.yml"
- import_tasks: "../tasks/netbox_query_interface.yml"
- import_tasks: "../tasks/netbox_evaluate_interface.yml"
no_log: true
- name: Define IP address object in NetBox
block:
- import_tasks: "../tasks/netbox_init_ip.yml"
- import_tasks: "../tasks/netbox_primaryip.yml"
no_log: true
- name: Start VM and attach console
import_tasks: "../tasks/init_vm_console.yml"
- name: Initialize SSH CA
import_tasks: "../tasks/init_ssh.yml"
- name: Assist guest OS installation
import_tasks: "../tasks/autoyast_assistant.yml"
- name: Wait for guest OS installation
import_tasks: "../tasks/wait.yml"
- name: Configure SSH
import_tasks: "../tasks/configure_ssh.yml"
always:
- name: Restore original tags
import_tasks: "../tasks/netbox_tags_post.yml"
- name: Remove lock
file:
path: "{{ lockfile }}"
state: absent
delegate_to: localhost
- name: Debug
ansible.builtin.debug:
msg: "{{ status if status is defined}} - {{ tags if tags is defined }} - {{ host if host is defined }} - {{ host_status if host_status is defined }} - {{ namespace if namespace is defined }} - {{ os if os is defined }} - {{ vcpus if vcpus is defined }} - {{ memory if memory is defined }} - {{ disk if disk is defined }}"
|