diff --git a/tasks/main.yml b/tasks/main.yml index 655d9ae..fd4fdb7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -10,13 +10,6 @@ tags: facts when: inventory_hostname not in groups.storage_boxes -- name: Set facts for storage storage boxes - ansible.builtin.set_fact: - ansible_date_time: - date: "{{ '%Y-%m-%d' | strftime }}" - time: "{{ '%H:%M:%S' | strftime }}" - when: inventory_hostname in groups.storage_boxes - - name: Create hypervisor items ansible.builtin.import_tasks: hypervisor.yml when: @@ -26,6 +19,11 @@ - hypervisor - server +- name: Gather storage box facts + ansible.builtin.import_tasks: storage_box.yml + tags: storage_box + when: inventory_hostname in groups.storage_boxes + - name: Create server items ansible.builtin.import_tasks: server.yml delegate_to: "{{ cmdb.wiki_server }}" diff --git a/tasks/storage_box.yml b/tasks/storage_box.yml new file mode 100644 index 0000000..8c08bf7 --- /dev/null +++ b/tasks/storage_box.yml @@ -0,0 +1,24 @@ +--- +- name: "Storage Box | Set facts for storage storage boxes" + ansible.builtin.set_fact: + ansible_date_time: + date: "{{ '%Y-%m-%d' | strftime }}" + time: "{{ '%H:%M:%S' | strftime }}" + +- name: "Storage Box | Scrap free space" + ansible.builtin.command: "df -h" + register: command_out + changed_when: false + +- name: "Storage Box | Set VM fact" + ansible.builtin.set_fact: + sb_space: "{{ command_out.stdout }}" + +- name: "Storage Box | Write Storage Box startpage" + ansible.builtin.template: + src: storage_boxes.txt.j2 + dest: "{{ cmdb.wiki_pages_path }}/servers/storage_boxes.txt" + owner: "{{ cmdb.wiki_user }}" + group: "{{ cmdb.wiki_group }}" + mode: "0644" + delegate_to: "{{ cmdb.wiki_server }}" diff --git a/templates/section_storage_boxes.txt.j2 b/templates/section_storage_boxes.txt.j2 index 9afdb7e..76c2e23 100644 --- a/templates/section_storage_boxes.txt.j2 +++ b/templates/section_storage_boxes.txt.j2 @@ -2,3 +2,5 @@ * {{ ansible_host }}:{{ ansible_port }} * {{ ansible_user }} + +{{ sb_space }}