From 4a87c023f8a029df1574fd45aae796b97e02de4c Mon Sep 17 00:00:00 2001 From: Lee Goolsbee Date: Thu, 28 Mar 2024 16:47:56 -0500 Subject: [PATCH] add managing individual lines in mesh.properties using values from template --- roles/bitbucket_mesh_config/defaults/main.yml | 2 ++ roles/bitbucket_mesh_config/tasks/main.yml | 8 ++++++++ roles/bitbucket_mesh_config/tasks/mesh_properties.yml | 11 +++++++++++ 3 files changed, 21 insertions(+) create mode 100644 roles/bitbucket_mesh_config/tasks/mesh_properties.yml diff --git a/roles/bitbucket_mesh_config/defaults/main.yml b/roles/bitbucket_mesh_config/defaults/main.yml index 493f907..dbb3b1a 100644 --- a/roles/bitbucket_mesh_config/defaults/main.yml +++ b/roles/bitbucket_mesh_config/defaults/main.yml @@ -1,4 +1,6 @@ --- +atl_mesh_properties_raw: "{{ lookup('env', 'ATL_MESH_PROPERTIES') }}" +atl_mesh_properties: "{{ atl_mesh_properties_raw.split(' ') | reject('equalto', '') | list }}" atl_mesh_volume_size: "{{ lookup('env', 'ATL_MESH_VOLUME_SIZE') or '50' }}" atl_mesh_azname_az1: "{{ lookup('env', 'ATL_MESH_AZNAME_AZ1') or '' }}" atl_mesh_azname_az2: "{{ lookup('env', 'ATL_MESH_AZNAME_AZ2') or '' }}" diff --git a/roles/bitbucket_mesh_config/tasks/main.yml b/roles/bitbucket_mesh_config/tasks/main.yml index 77764ce..7c2086a 100644 --- a/roles/bitbucket_mesh_config/tasks/main.yml +++ b/roles/bitbucket_mesh_config/tasks/main.yml @@ -64,6 +64,14 @@ - new_meshvol_from_snap is defined - new_meshvol_from_snap | bool +# handle adding/updating some ansible managed mesh properties +- name: Import management of additional ansible-managed mesh properties + ansible.builtin.import_tasks: + file: mesh_properties.yml + when: + - atl_mesh_properties is defined + - atl_mesh_properties | length > 0 + # handle reregistering the correct node if node.id exists - name: Set mesh_node_id var from the existing mesh.properties file ansible.builtin.set_fact: diff --git a/roles/bitbucket_mesh_config/tasks/mesh_properties.yml b/roles/bitbucket_mesh_config/tasks/mesh_properties.yml new file mode 100644 index 0000000..31aa8a6 --- /dev/null +++ b/roles/bitbucket_mesh_config/tasks/mesh_properties.yml @@ -0,0 +1,11 @@ +--- +# Rather than managing the entire mesh.properties file, we only manage individual +# properties because upstream the product sets some properties by editing the file +- name: Update additional ansible-managed mesh properties + ansible.builtin.lineinfile: + path: "{{ mesh_properties_file }}" + search_string: "{{ mesh_prop_key }}=" + line: "{{ item }}" + vars: + mesh_prop_key: "{{ item.split('=') | first }}" + loop: "{{ atl_mesh_properties }}"