Skip to content

Commit 086837f

Browse files
committed
Add update tasks for movement of config files to new locations
This will ensure that we don't have issues during update Signed-off-by: rabi <[email protected]>
1 parent 76d8b04 commit 086837f

File tree

13 files changed

+901
-2
lines changed

13 files changed

+901
-2
lines changed

roles/edpm_frr/tasks/update.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
# Copyright 2023 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
- name: Ensure new config directory exists
17+
tags:
18+
- update
19+
- frr
20+
become: true
21+
ansible.builtin.file:
22+
path: "{{ edpm_frr_config_basedir }}"
23+
state: directory
24+
setype: "container_file_t"
25+
owner: "{{ ansible_user | default(ansible_user_id) }}"
26+
group: "{{ ansible_user | default(ansible_user_id) }}"
27+
mode: "0755"
28+
29+
- name: Ensure config subdirectory exists
30+
tags:
31+
- update
32+
- frr
33+
become: true
34+
ansible.builtin.file:
35+
path: "{{ edpm_frr_config_basedir }}/etc/frr"
36+
state: directory
37+
setype: "container_file_t"
38+
owner: "{{ ansible_user | default(ansible_user_id) }}"
39+
group: "{{ ansible_user | default(ansible_user_id) }}"
40+
mode: "0755"
41+
42+
- name: Check if old config directory exists
43+
tags:
44+
- update
45+
- frr
46+
ansible.builtin.stat:
47+
path: "/var/lib/config-data/ansible-generated/frr"
48+
register: edpm_frr_old_config_dir
49+
50+
- name: Move config files from old location to new location
51+
tags:
52+
- update
53+
- frr
54+
become: true
55+
when:
56+
- edpm_frr_old_config_dir.stat.exists
57+
- edpm_frr_old_config_dir.stat.isdir
58+
block:
59+
- name: Find config files in old location
60+
ansible.builtin.find:
61+
paths: "/var/lib/config-data/ansible-generated/frr"
62+
file_type: file
63+
recurse: true
64+
register: edpm_frr_old_config_files
65+
66+
- name: Copy config files to new location
67+
ansible.builtin.copy:
68+
src: "{{ item.path }}"
69+
dest: "{{ edpm_frr_config_basedir }}/{{ item.path | regex_replace('^.*/frr/', '') }}"
70+
remote_src: true
71+
setype: "container_file_t"
72+
mode: "0644"
73+
loop: "{{ edpm_frr_old_config_files.files }}"
74+
when:
75+
- edpm_frr_old_config_files.files is defined
76+
- edpm_frr_old_config_files.files | length > 0
77+
78+
- name: Remove old config directory
79+
ansible.builtin.file:
80+
path: "/var/lib/config-data/ansible-generated/frr"
81+
state: absent
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
# Copyright 2023 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
- name: Gather user fact
17+
ansible.builtin.setup:
18+
gather_subset:
19+
- "!all"
20+
- "!min"
21+
- "user"
22+
when:
23+
- ansible_user is undefined
24+
25+
- name: Ensure new config directory exists
26+
tags:
27+
- update
28+
- neutron_dhcp
29+
become: true
30+
ansible.builtin.file:
31+
path: "{{ edpm_neutron_dhcp_agent_config_dir }}"
32+
state: directory
33+
setype: "container_file_t"
34+
owner: "{{ ansible_user | default(ansible_user_id) }}"
35+
group: "{{ ansible_user | default(ansible_user_id) }}"
36+
mode: "0755"
37+
38+
- name: Check if old config directory exists
39+
tags:
40+
- update
41+
- neutron_dhcp
42+
ansible.builtin.stat:
43+
path: "/var/lib/config-data/ansible-generated/neutron-dhcp-agent"
44+
register: edpm_neutron_dhcp_old_config_dir
45+
46+
- name: Move config files from old location to new location
47+
tags:
48+
- update
49+
- neutron_dhcp
50+
become: true
51+
when:
52+
- edpm_neutron_dhcp_old_config_dir.stat.exists
53+
- edpm_neutron_dhcp_old_config_dir.stat.isdir
54+
block:
55+
- name: Find config files in old location
56+
ansible.builtin.find:
57+
paths: "/var/lib/config-data/ansible-generated/neutron-dhcp-agent"
58+
file_type: file
59+
recurse: false
60+
register: edpm_neutron_dhcp_old_config_files
61+
62+
- name: Copy config files to new location
63+
ansible.builtin.copy:
64+
src: "{{ item.path }}"
65+
dest: "{{ edpm_neutron_dhcp_agent_config_dir }}/{{ item.path | basename }}"
66+
remote_src: true
67+
setype: "container_file_t"
68+
owner: "{{ ansible_user | default(ansible_user_id) }}"
69+
group: "{{ ansible_user | default(ansible_user_id) }}"
70+
mode: "0644"
71+
loop: "{{ edpm_neutron_dhcp_old_config_files.files }}"
72+
when:
73+
- edpm_neutron_dhcp_old_config_files.files is defined
74+
- edpm_neutron_dhcp_old_config_files.files | length > 0
75+
76+
- name: Remove old config directory
77+
ansible.builtin.file:
78+
path: "/var/lib/config-data/ansible-generated/neutron-dhcp-agent"
79+
state: absent
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
# Copyright 2023 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
- name: Gather user fact
17+
ansible.builtin.setup:
18+
gather_subset:
19+
- "!all"
20+
- "!min"
21+
- "user"
22+
when:
23+
- ansible_user is undefined
24+
25+
- name: Ensure new config directory exists
26+
tags:
27+
- update
28+
- neutron_metadata
29+
become: true
30+
ansible.builtin.file:
31+
path: "{{ edpm_neutron_metadata_agent_config_dir }}"
32+
state: directory
33+
setype: "container_file_t"
34+
owner: "{{ ansible_user | default(ansible_user_id) }}"
35+
group: "{{ ansible_user | default(ansible_user_id) }}"
36+
mode: "0755"
37+
38+
- name: Check if old config directory exists
39+
tags:
40+
- update
41+
- neutron_metadata
42+
ansible.builtin.stat:
43+
path: "/var/lib/config-data/ansible-generated/neutron-ovn-metadata-agent"
44+
register: edpm_neutron_metadata_old_config_dir
45+
46+
- name: Move config files from old location to new location
47+
tags:
48+
- update
49+
- neutron_metadata
50+
become: true
51+
when:
52+
- edpm_neutron_metadata_old_config_dir.stat.exists
53+
- edpm_neutron_metadata_old_config_dir.stat.isdir
54+
block:
55+
- name: Find config files in old location
56+
ansible.builtin.find:
57+
paths: "/var/lib/config-data/ansible-generated/neutron-ovn-metadata-agent"
58+
file_type: file
59+
recurse: false
60+
register: edpm_neutron_metadata_old_config_files
61+
62+
- name: Copy config files to new location
63+
ansible.builtin.copy:
64+
src: "{{ item.path }}"
65+
dest: "{{ edpm_neutron_metadata_agent_config_dir }}/{{ item.path | basename }}"
66+
remote_src: true
67+
setype: "container_file_t"
68+
owner: "{{ ansible_user | default(ansible_user_id) }}"
69+
group: "{{ ansible_user | default(ansible_user_id) }}"
70+
mode: "0644"
71+
loop: "{{ edpm_neutron_metadata_old_config_files.files }}"
72+
when:
73+
- edpm_neutron_metadata_old_config_files.files is defined
74+
- edpm_neutron_metadata_old_config_files.files | length > 0
75+
76+
- name: Remove old config directory
77+
ansible.builtin.file:
78+
path: "/var/lib/config-data/ansible-generated/neutron-ovn-metadata-agent"
79+
state: absent
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
# Copyright 2023 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
- name: Gather user fact
17+
ansible.builtin.setup:
18+
gather_subset:
19+
- "!all"
20+
- "!min"
21+
- "user"
22+
when:
23+
- ansible_user is undefined
24+
25+
- name: Ensure new config directory exists
26+
tags:
27+
- update
28+
- neutron_ovn
29+
become: true
30+
ansible.builtin.file:
31+
path: "{{ edpm_neutron_ovn_agent_config_dir }}"
32+
state: directory
33+
setype: "container_file_t"
34+
owner: "{{ ansible_user | default(ansible_user_id) }}"
35+
group: "{{ ansible_user | default(ansible_user_id) }}"
36+
mode: "0755"
37+
38+
- name: Check if old config directory exists
39+
tags:
40+
- update
41+
- neutron_ovn
42+
ansible.builtin.stat:
43+
path: "/var/lib/config-data/ansible-generated/neutron-ovn-agent"
44+
register: edpm_neutron_ovn_old_config_dir
45+
46+
- name: Move config files from old location to new location
47+
tags:
48+
- update
49+
- neutron_ovn
50+
become: true
51+
when:
52+
- edpm_neutron_ovn_old_config_dir.stat.exists
53+
- edpm_neutron_ovn_old_config_dir.stat.isdir
54+
block:
55+
- name: Find config files in old location
56+
ansible.builtin.find:
57+
paths: "/var/lib/config-data/ansible-generated/neutron-ovn-agent"
58+
file_type: file
59+
recurse: false
60+
register: edpm_neutron_ovn_old_config_files
61+
62+
- name: Copy config files to new location
63+
ansible.builtin.copy:
64+
src: "{{ item.path }}"
65+
dest: "{{ edpm_neutron_ovn_agent_config_dir }}/{{ item.path | basename }}"
66+
remote_src: true
67+
setype: "container_file_t"
68+
owner: "{{ ansible_user | default(ansible_user_id) }}"
69+
group: "{{ ansible_user | default(ansible_user_id) }}"
70+
mode: "0644"
71+
loop: "{{ edpm_neutron_ovn_old_config_files.files }}"
72+
when:
73+
- edpm_neutron_ovn_old_config_files.files is defined
74+
- edpm_neutron_ovn_old_config_files.files | length > 0
75+
76+
- name: Remove old config directory
77+
ansible.builtin.file:
78+
path: "/var/lib/config-data/ansible-generated/neutron-ovn-agent"
79+
state: absent

0 commit comments

Comments
 (0)