-
Notifications
You must be signed in to change notification settings - Fork 20
/
adhoc-deploy-ci-seamicro.yml
108 lines (94 loc) · 3.65 KB
/
adhoc-deploy-ci-seamicro.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
---
# This ad-hoc playbook is written only to support Seamicro Chassis (now dead product)
# It uses some variables like user/pass to access Chassis rest API and configure/reset compute nodes
# By default, for CI purposes we are ensuring that we add a second path to chassis/fabric to present multipath and so increase available bandwdith during tests
- hosts: "{{ node_name }}"
gather_facts: False
become: False
# Some pre-defined list that will be added for 'uri' module and converted to json for rest api
vars:
seamicro_add_disk_body:
value: "{{ seamicro_diskid }}"
readonly: false
username: "{{ seamicro_chassis_user }}"
password: "{{ seamicro_chassis_pass }}"
seamicro_reset_body:
action: reset
using-pxe: "true"
username: "{{ seamicro_chassis_user }}"
password: "{{ seamicro_chassis_pass }}"
seamicro_poweroff_body:
action: power-off
force: "true"
username: "{{ seamicro_chassis_user }}"
password: "{{ seamicro_chassis_pass }}"
tasks:
- block:
- name: "Generate tftp config [{{ centos_dist }}] for Seamicro node"
template:
src: pxeboot.j2
dest: "/var/lib/tftpboot/pxelinux.cfg/01-{{ mac_address | lower | replace(':','-') }}"
mode: 0755
tags:
- pxe
- name: "Generate kickstart file [{{centos_dist }}] for Seamicro node[s]"
template:
src: "{{ item }}"
dest: "/var/www/html/ks/{{ inventory_hostname }}-ks.cfg"
mode: 0755
with_first_found:
- "../templates/kickstarts/ci-centos-{{ centos_dist }}-ks.j2"
tags:
- pxe
- ks
delegate_to: "{{ deploy_node }}"
- block:
- name: Deleting additional path to the Seamicro node[s]
uri:
url: "https://{{ seamicro_chassis }}.ci.centos.org/v2.0/server/{{ seamicro_srvid }}/vdisk/{{ seamicro_vdisk_slot }}?username={{ seamicro_chassis_user }}&password={{ seamicro_chassis_pass }}"
validate_certs: no
method: DELETE
status_code: 200,400
timeout: 120
- name: Wait for the disk to be removed
uri:
url: "https://{{ seamicro_chassis }}.ci.centos.org/v2.0/server/{{ seamicro_srvid }}/vdisk/{{ seamicro_vdisk_slot }}?username={{ seamicro_chassis_user }}&password={{ seamicro_chassis_pass }}"
validate_certs: no
method: GET
timeout: 120
status_code: 200,201,404
register: http_result
until: http_result['status'] == 404
retries: 5
delay: 10
- name: Adding additional path to vdisk to the Seamicro node[s]
uri:
url: "https://{{ seamicro_chassis }}.ci.centos.org/v2.0/server/{{ seamicro_srvid }}/vdisk/{{ seamicro_vdisk_slot }}"
validate_certs: no
method: PUT
body_format: json
body: "{{ seamicro_add_disk_body | to_json }}"
status_code: 201
timeout: 120
- name: Resetting the Seamicro node[s]
uri:
url: "https://{{ seamicro_chassis }}.ci.centos.org/v2.0/server/{{ seamicro_srvid }}"
validate_certs: no
method: POST
body_format: json
body: "{{ seamicro_reset_body | to_json }}"
timeout: 180
tags:
- reset
- name: Waiting for Seamicro node[s] to be available through ssh
wait_for:
port: 22
host: "{{ ip }}"
timeout: 1200
- name: Sending back useful information for duffy provisioner
set_fact:
duffy_out:
nodes:
- hostname: "{{ node_name }}"
ipaddr: "{{ ip }}"
delegate_to: localhost