blob: e811291be4fb1aecc76de5b4e08ff2f71c397929 (
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
|
---
- name: Evaluate cluster
block:
- name: Increment counters
set_fact:
retry_count: "{{ 0 if retry_count is undefined else retry_count | int +1 }}"
host_count: "{{ 0 if retry_count is undefined else host_count | int +1 }}"
- name: Pick cluster host
set_fact:
#host_choice: "{{ nb_hosts.json.results[nb_hosts.json.count | random | int] }}" #PICK RANDOM
#host_choice: "{{ nb_hosts.json.results[1] }}" #FAIL TEST
host_choice: "{{ nb_hosts.json.results[host_count | int] }}" #INCREMENT
no_log: true
- name: Evaluate cluster host status
set_fact:
host_status: "{{ host_choice.status.value }}"
#register: host_status
- name: Evaluate cluster host name
set_fact:
host: "{{ host_choice.name }}"
- name: Evaluate cluster host status
fail:
msg: Host is not ready.
when: host_status != 'active'
- name: Evaluate cluster host configuration
block:
- name: Cluster derived variables 1/2
set_fact:
storage: "{{ host_choice.config_context.storage[0] }}"
deployment_servers: "{{ host_choice.config_context.deployment_servers }}"
dhcp_servers: "{{ host_choice.config_context.dhcp_servers }}"
dns_servers: "{{ host_choice.config_context.dns_servers }}"
namespace: "{{ host_choice.config_context.namespace }}"
gateway: "{{ host_choice.config_context.gateway }}"
- name: Cluster derived variables 2/2
set_fact:
namespace_short: "{{ namespace.split('.')[0] }}"
when: host_status == 'active'
tags:
- init_dp
- init_ssh
rescue:
- name: Check retry counter
fail:
msg: "Too many retries - no host is ready"
when: retry_count | int == 3 and host_status != 'active'
- debug:
msg: "{{ host if host is defined }} - {{ host_status if host_status is defined }}"
- name: Re-evaluate cluster
include_tasks: "../tasks/netbox_evaluate_cluster.yml"
when: host_status != 'active'
|