diff --git a/roles/sunstone_view/defaults/main.yml b/roles/sunstone_view/defaults/main.yml new file mode 100644 index 0000000..d7643cf --- /dev/null +++ b/roles/sunstone_view/defaults/main.yml @@ -0,0 +1,20 @@ +--- +# Identifier for the view (e.g., custom_view) +sunstone_view_name: custom_view + +# Display name for the view +sunstone_view_label: Custom + +# Description for the view +sunstone_view_description: Custom view description + +# List of groups to add this view to +sunstone_view_groups: + - oneadmin + +# Folder name in inventory/views/ to copy from +sunstone_view_source_folder: custom_view + +# Destination paths on the frontend +sunstone_views_config_file: /etc/one/fireedge/sunstone/views/sunstone-views.yaml +sunstone_views_base_dir: /etc/one/fireedge/sunstone/views/ diff --git a/roles/sunstone_view/tasks/main.yml b/roles/sunstone_view/tasks/main.yml new file mode 100644 index 0000000..9f43a69 --- /dev/null +++ b/roles/sunstone_view/tasks/main.yml @@ -0,0 +1,40 @@ +--- +- name: Copy view folder + ansible.builtin.copy: + src: "{{ inventory_dir }}/views/{{ sunstone_view_source_folder }}/" + dest: "{{ sunstone_views_base_dir }}{{ sunstone_view_name }}/" + mode: u=rw,g=r,o=r + +- name: Update views definition in sunstone-views.yaml + opennebula.deploy.cfgtool: + dest: "{{ sunstone_views_config_file }}" + parser: Yaml + actions: + - put: + path: [views, "{{ sunstone_view_name }}"] + value: + name: "{{ sunstone_view_label }}" + description: "{{ sunstone_view_description }}" + +- name: Add view to groups in sunstone-views.yaml + opennebula.deploy.cfgtool: + dest: "{{ sunstone_views_config_file }}" + parser: Yaml + actions: + - get: + path: [groups, "{{ item }}"] + register: _groups_cfg + loop: "{{ sunstone_view_groups }}" + changed_when: false + +- name: Update group views list + opennebula.deploy.cfgtool: + dest: "{{ sunstone_views_config_file }}" + parser: Yaml + actions: + - put: + path: [groups, "{{ item.item }}", 0] + value: "{{ sunstone_view_name }}" + loop: "{{ _groups_cfg.results }}" + # item.values[0] is the list of views for the group + when: sunstone_view_name not in item['values'][0]