On Thu, 18 May 2023 at 03:14, Sac Isilia <[email protected]>
wrote:

> Hi Team,
>
> Below is the jinja template that I wrote that works fine on existing RHEL
> 7 machine .
>
> ```
> UUID={{
> hostvars['localhost']['ansible_facts']['device_links']['uuids']['xvda2'][0]
> }}    /  {{ ansible_facts['mounts'][0].fstype }}  defaults 0 0
>



> UUID_home={{
> hostvars['localhost']['ansible_facts']['device_links']['uuids']['xvdb'][0]
>  }}
>



 /home  {{ ansible_facts['mounts'][0].fstype }}  defaults 0 0
> UUID_var={{
> hostvars['localhost']['ansible_facts']['device_links']['uuids']['xvdc'][0]
>  }}    /var  {{ ansible_facts['mounts'][0].fstype }}  defaults 0 0
> UUID_swap={{
> hostvars['localhost']['ansible_facts']['device_links']['uuids']['xvdd'][0]
> }}   swap  swap  defaults 0 0
> ```
>
> It works fine on existing test RHEL 7 machine but it fails when I am
> trying to run this template in our Jenkins job with below error.
>
> ```
> An exception occurred during task execution. To see the full traceback,
> use -vvv. The error was: AnsibleUndefinedVariable: 'dict object' has no
> attribute 'xvdb'
> ```
>
> I tried running ansible localhost -m setup and the above paths actually
> exist and xvdb entry is also there. My main doubt is the playbook parsed
> xvda2 line but fails at xvdb. Why? Below is the relevant output of ansible
> setup command.
>
> ```
>


\"ansible_device_links\": {",
>

This is different from what you have in the template:

hostvars['localhost']['ansible_facts']['device_links']

Also are you sure this "Jenkins" is targeting the right host? That could be
the problem.




>     "            \"ids\": {}, ",
>        "            \"labels\": {}, ",
>        "            \"masters\": {}, ",
>        \"uuids\": {",
>           \"xvda2\": [",
>                  \"87be522b-2b75-4150-879d-4ee109559f7e\"",
>      ], ",
>            \"xvdb\": [",
>                 \"da750c25-cc98-4c2a-a5fe-24bbf42c210e\"",
>      "                ], ",
>      "      \"xvdc\": [",
>      "                    \"c2d5f1dc-5840-40bf-9a54-bb8fb215fbec\"",
>      "                ], ",
>      "        \"xvdd\": [",
>      "                    \"3b78b0ff-cc18-49ff-80b4-f21ca0a1234e\"",
>     "                ]",
>      "            }",
>     "        }, ",
> ```
>
> Please help me to resolve this
>
> Regards
> Sachin Kumar
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/52ff8092-399f-48ab-901a-228ce8c16c0cn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/52ff8092-399f-48ab-901a-228ce8c16c0cn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
-- 
Sent from Gmail Mobile

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLZPaZ7xzOFyevWMzV4P79H%2B38Nv9i1%2B0CFqM_PmHA9EDQ%40mail.gmail.com.

Reply via email to