Hello Team, I have spent a lot of time trying troubleshoot this issue. I have a roles with defined variable This is inside defaults/main.yml nessus_agent_package: - redhat7: - al2: ./files/NessusAgent-8.3.1-amzn.x86_64.rpm - al1: and my tasks main.yml has an include which will identify the server and include an appropriate files inside - name: include distribution specific install YAML files include: "{{ ansible_distribution }}.yml"
Those files are present on tasks level -rw-r--r--. 1 root root 740 Oct 5 20:49 Amazon.yml -rw-r--r--. 1 root root 260 Oct 5 08:41 Debian.yml -rw-r--r--. 1 root root 1024 Oct 5 07:39 main.yml -rw-r--r--. 1 root root 1040 Oct 5 08:55 RedHat.yml -rw-r--r--. 1 root root 1031 Oct 5 08:57 SUSE.yml -rw-r--r--. 1 root root 260 Oct 5 08:02 Ubuntu.yml Now I'm deploying the code inside an Amazon EC2 Linux 2 system which after gather the facts was routed to select Amazon.yml file. --- # ./roles/tenableagent/tasks/amazon.yml - name: Install Nessus Agent for Amzon 2 from repo package: name: "{{ item.al2 }}" update_cache: yes cache_valid_time: "{{apt_cache_valid_time | default (omit)}}" loop: "{{ nessus_agent_package }}" when: ansible_facts['distribution'] == "Amazon" and ansible_facts['distribution_major_version'] == "2")" .Now when running the playbooks. I'm getting bellow error. Please can you help me out PLAY [all] *************************************************************************************************************************************************************************************************** TASK [Gathering Facts] *************************************************************************************************************************************************************************************** [WARNING]: Platform linux on host ec2-52-91-173-242.compute-1.amazonaws.com is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. ok: [ec2-52-91-173-242.compute-1.amazonaws.com] TASK [tenableagent : include distribution specific install YAML files] *************************************************************************************************************************************** included: /root/nessus-agent/roles/tenableagent/tasks/Amazon.yml for ec2-52-91-173-242.compute-1.amazonaws.com TASK [tenableagent : Install Nessus Agent for Amzon 2 from repo] ********************************************************************************************************************************************* fatal: [ec2-52-91-173-242.compute-1.amazonaws.com]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'al2'\n\nThe error appears to be in '/root/nessus-agent/roles/tenableagent/tasks/Amazon.yml': line 3, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# ./roles/tenableagent/tasks/amazon.yml\n- name: Install Nessus Agent for Amzon 2 from repo\n ^ here\n"} PLAY RECAP *************************************************************************************************************************************************************************************************** ec2-52-91-173-242.compute-1.amazonaws.com : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5eafe96b-beb2-4b61-b735-058e9e43128cn%40googlegroups.com.