---
-
  name: "Setting timezone to {{ timezone }}"
  community.general.timezone:
    name: "{{ timezone }}"

-
  name: "Creating Directories"
  ansible.builtin.file:
    path: "{{ item }}"
    state: directory
    mode: 0777
  with_items:
    - "{{ completed_dir }}"
    - "/root/.ansible/tmp"
    - "/vagrant/support-bundle"

-
  name: "Writing current variables to /vagrant/support-bundle/ansible-system-variables.json"
  ansible.builtin.copy:
    content: "{{ vars }}"
    dest: "/vagrant/support-bundle/ansible-system-variables.json"
    force: false
    mode: 'a+x'

-
  name: "Printing out Demo Tasks Version used"
  ansible.builtin.debug:
    msg: "This Ansible Playbook was Generated with DemoTasks v{{ demo_tasks_version }}"

-
  name: "Writing current variables to /vagrant/support-bundle/version.json"
  ansible.builtin.copy:
    content: "{{ demo_tasks_version }}"
    dest: "/vagrant/support-bundle/version.json"
    force: false
    mode: 'a+x'

-
  name: "Extracting Networking Adapters"
  when: networks[0] is defined
  ansible.builtin.shell: lshw -xml -c net
  args:
    executable: /bin/bash
  register: adapters

-
  name: "Writing current variables to /vagrant/support-bundle/adapters.json"
  when: networks[0] is defined
  ansible.builtin.copy:
    content: "{{ adapters.stdout_lines }}"
    dest: "/vagrant/support-bundle/adapters.json"
    force: false
    mode: 'a+x'

-
  name: "Extracting MAC address of bridged adapter"
  when: networks[0] is defined
  ansible.builtin.shell: set -o pipefail && lshw -xml -c net | xmllint --xpath "string(//node[@id='network']/serial|//node[@id='network:1']/serial)" -
  args:
    executable: /bin/bash
  register: macaddress

-
  name: "Writing current variables to /vagrant/support-bundle/bridged-macaddress.json"
  when: networks[0] is defined
  ansible.builtin.copy:
    content: "{{ macaddress.stdout_lines }}"
    dest: "/vagrant/support-bundle/bridged-macaddress.json"
    force: false
    mode: 'a+x'
