This is my script:
---
- name: Update Red Hat system and lock version
  hosts: "{{host}}"
  become: true
  tasks:
    - debug: msg="Host is {{ ansible_fqdn }}"
    
    - name: install dnf versionlock plugin
      dnf:
        name: dnf-plugin-versionlock
        state: latest
    - name: unlock all packages
      shell: dnf versionlock delete "*"
    - name: Update all packages
      dnf:
        name: '*'
        state: latest
  
    - name: lock all packages
      shell: dnf versionlock add "*"
        
    - name: send list of locked packages to remote host
      fetch:
        src: /etc/dnf/plugins/versionlock.list
        dest: ansible/inventory/dnf_lockFiles/versionlock.list
        flat: yes
In the last step I would like to create a folder under ansible/inventory/dnf_lockFiles/ that has the name of the inventory file.
For example if the inventory being used has the name test then the path created would look like this: ansible/inventory/dnf_lockFiles/test/versionlock.list.
How do I use the name of the inventory as a variable?
 
    