-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetchfiles.yml
97 lines (88 loc) · 4.35 KB
/
fetchfiles.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
- name: Fetch files from URLs to locations onto Undercloud as well as into Overcloud image
hosts: undercloud
gather_facts: yes
any_errors_fatal: true
tasks:
- name: Fetch files onto Undercloud
vars:
_url: "{{ item.split(',')[0] }}"
_destfile: "{{ item.split(',')[1] }}"
get_url:
url: "{{ _url }}"
dest: "{{ _destfile }}"
backup: yes
force: yes
validate_certs: no
timeout: 5
register: fetchfiles_undercloud_result
until: fetchfiles_undercloud_result.msg.find("Request failed") == -1
retries: 5
delay: 5
become: true
with_items: "{{ install.get('fetchfiles', {}).get('undercloud', {}) }}"
- block:
- name: wipe out /tmp/fetchfiles_overcloud/ directory
file:
path: /tmp/fetchfiles_overcloud/
state: "{{ item }}"
with_items:
- absent
- directory
- name: create directories structure (under /tmp/fetchfiles_overcloud/) that will be used to fetch files from URLs and later to upload them to overcloud image
vars:
_destdir: "/tmp/fetchfiles_overcloud/{{ item.split(',')[1] | dirname }}"
file:
state: directory
path: "{{ _destdir }}"
with_items: "{{ install.get('fetchfiles', {}).get('overcloud', {}) }}"
- name: Fetch files into directories under /tmp/fetchfiles_overcloud/
vars:
_url: "{{ item.split(',')[0] }}"
_destfile: "/tmp/fetchfiles_overcloud/{{ item.split(',')[1] }}"
get_url:
url: "{{ _url }}"
dest: "{{ _destfile }}"
backup: yes
force: yes
validate_certs: no
timeout: 5
register: fetchfiles_overcloud_result
until: fetchfiles_overcloud_result.msg.find("Request failed") == -1
retries: 5
delay: 5
become: true
with_items: "{{ install.get('fetchfiles', {}).get('overcloud', {}) }}"
- name: wipe out /tmp/fetchfiles_overcloud_image directory
file:
path: /tmp/fetchfiles_overcloud_image
state: "{{ item }}"
with_items:
- absent
- directory
- name: Save overcloud images from glance to files in /tmp/fetchfiles_overcloud_image/
shell: |
source ~/stackrc
openstack image save --file /tmp/fetchfiles_overcloud_image/overcloud-full.qcow2 overcloud-full
openstack image save --file /tmp/fetchfiles_overcloud_image/overcloud-full.initrd overcloud-full-initrd
openstack image save --file /tmp/fetchfiles_overcloud_image/overcloud-full.vmlinuz overcloud-full-vmlinuz
- name: Save Ironic Python Agent images from glance to files (we don't actually modify these but they're required to re-upload the overcloud-full image to glance)
shell: |
source ~/stackrc
openstack image save --file /tmp/fetchfiles_overcloud_image/ironic-python-agent.initramfs bm-deploy-ramdisk
openstack image save --file /tmp/fetchfiles_overcloud_image/ironic-python-agent.kernel bm-deploy-kernel
openstack image save --file /tmp/fetchfiles_overcloud_image/ironic-python-agent.kernel bm-deploy-kernel
- name: set paths_to_upload fact
set_fact:
paths_to_upload: "{{ paths_to_upload | default('') }} --upload /tmp/fetchfiles_overcloud/{{ item.split(',')[1] }}:{{ item.split(',')[1] | dirname }}"
with_items: "{{ install.get('fetchfiles', {}).get('overcloud', {}) }}"
no_log: true
- name: Inject fetchfiles into overcloud image
shell: LIBGUESTFS_BACKEND=direct virt-customize -a /tmp/fetchfiles_overcloud_image/overcloud-full.qcow2 \
{{ paths_to_upload }}
become: true
tags: skip_ansible_lint
- name: upload updated overcloud-full image to glance
shell: |
source ~/stackrc
openstack overcloud image upload --update-existing --image-path /tmp/fetchfiles_overcloud_image/
when: install.get('fetchfiles', {}).get('overcloud', {})