Newer
Older
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
- name: proxy
when:
- proxy_http | d()
- proxy_https | d()
include_role:
name: proxy
- name: install requirements
apt:
force_apt_get: true
install_recommends: false
name: "{{ conf_req_packages }}"
register: apt_status
retries: 60
until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)
- name: install online requirements
when: not offline_mode | d(false)
apt:
force_apt_get: true
install_recommends: false
name: "{{ conf_req_packages_online }}"
register: apt_status
retries: 60
until: apt_status is success or ('Failed to lock apt for exclusive operation' not in apt_status.msg and '/var/lib/dpkg/lock' not in apt_status.msg)
- name: clone envsetup repository
when: not offline_mode | d(false)
ignore_errors: true
register: conf_clone
git:
repo: "{{ conf_repo_url }}"
version: "{{ conf_repo_version }}"
dest: "{{ conf_repo_dest }}"
- name: ask to continue
when:
- not offline_mode | d(false)
- conf_clone is failed
pause:
prompt: "Previous task failed, it may be normal if you have local changes in the commited files, do you want to continue anyway?"
seconds: 30
- name: generate root ssh key pair
register: conf_root
user:
name: root
generate_ssh_key: true
ssh_key_type: ed25519
ssh_key_file: .ssh/id_ed25519
- name: check if auto-generated-conf.sh exists
check_mode: false
register: check_conf
stat:
path: "{{ conf_repo_dest }}/auto-generated-conf.sh"
- name: check if conf.sh exists
check_mode: false
register: check_local_conf
stat:
path: "{{ conf_repo_dest }}/conf.sh"
- name: download conf and update ssh public key with activation key
when: skyreach_activation_key | d(false)
register: conf_dl_ak
changed_when: conf_dl_ak.status == 200
failed_when:
- conf_dl_ak.status != 200
- not check_conf.stat.exists
- not skyreach_system_key
uri:
url: https://{{ conf_host }}/erp/credentials/envsetup-conf.sh
method: POST
body_format: form-urlencoded
body:
key: "{{ skyreach_activation_key }}"
public_key: "{{ conf_root.ssh_public_key }}"
return_content: true
validate_certs: "{{ conf_valid_cert }}"
- name: download conf and update ssh public key with system key
when:
- not check_conf.stat.exists or conf_update
- skyreach_system_key | d(false)
register: conf_dl_sk
changed_when: conf_dl_sk.status == 200
failed_when:
- conf_dl_sk.status != 200
- not check_conf.stat.exists
uri:
url: https://{{ conf_host }}/erp/credentials/envsetup-conf.sh
method: POST
body_format: form-urlencoded
body:
api_key: "{{ skyreach_system_key }}"
public_key: "{{ conf_root.ssh_public_key }}"
return_content: true
validate_certs: "{{ conf_valid_cert }}"
- name: save generated conf
loop:
- "{{ conf_dl_ak }}"
- "{{ conf_dl_sk }}"
when: item is changed
copy:
content: "{{ item.content }}"
dest: "{{ conf_repo_dest }}/auto-generated-conf.sh"
force: true
backup: true
- name: touch generated conf
file:
path: "{{ conf_repo_dest }}/auto-generated-conf.sh"
access_time: preserve
modification_time: preserve
state: touch
- name: touch local conf
file:
path: "{{ conf_repo_dest }}/conf.sh"
access_time: preserve
modification_time: preserve
state: touch
- name: load global conf
changed_when: false
check_mode: false
source_file:
path: "{{ conf_repo_dest }}/global-conf.sh"
prefix: envsetup_
lower: true
- name: load generated conf
changed_when: false
check_mode: false
source_file:
path: "{{ conf_repo_dest }}/auto-generated-conf.sh"
prefix: envsetup_
lower: true
- name: load local conf
changed_when: false
check_mode: false
source_file:
path: "{{ conf_repo_dest }}/conf.sh"
prefix: envsetup_
lower: true
- name: debug variables
when: conf_debug
debug:
var: ansible_facts
...