Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute 'xvdb'

2023-05-18 Thread Dick Visser
On Thu, 18 May 2023 at 08:44, Sac Isilia  wrote:
>
> Hi Team,
>
> I have changed to standard jinja2 template , even then the error is same. It 
> fails to find xvdb but it finds xvda2 . The syntax to extract UUID is same 
> and both values are present in the ansible localhost -m setup command output 
> . This playbook is running on localhost only.

There is nothing wrong with the template.
The problem is that the playbook is not run against the host that you
think it is run.
And because they have a similar partitioning setup, a few common
devices exist, but some other do not.
So, it's not really an ansible problem, but rather a problem with how
you invoke ansible, in your environment.
That consists of "existing test RHEL 7 machine", a "jenkins" system,
and various incarnations of "localhost".
Try to get that clear a bit.

-- 
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/CAF8BbLbZGnr8OYcXKiRsk82xJ%2BFsOrUH4HFVghGGBdeBHbw%3DFw%40mail.gmail.com.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute 'xvdb'

2023-05-18 Thread Sac Isilia
Hi Team,

I have changed to standard jinja2 template , even then the error is same. 
It fails to find xvdb but it finds xvda2 . The syntax to extract UUID is 
same and both values are present in the ansible localhost -m setup command 
output . This playbook is running on localhost only.

```
UUID={{ ansible_facts['device_links']['uuids']['xvda2'][0] }}/  {{ 
ansible_facts['mounts'][0].fstype }}  defaults 0 0
UUID_home={{ ansible_facts['device_links']['uuids']['xvdb'][0]  }}/home 
 {{ ansible_facts['mounts'][0].fstype }}  defaults 0 0
UUID_var={{ ansible_facts['device_links']['uuids']['xvdc'][0]  }}/var 
 {{ ansible_facts['mounts'][0].fstype }}  defaults 0 0
UUID_swap={{ ansible_facts['device_links']['uuids']['xvdd'][0] }}   swap 
 swap  defaults 0 0
```

Regards
Sachin Kumar

On Thursday, May 18, 2023 at 11:42:51 AM UTC+5:30 Sac Isilia wrote:

> Hi Team,
>
> The standard way to access is - 
> ansible_facts['device_links']['uuids']['xvdb'][0] . It works on existing 
> rhel 7 machine but it fails there. Also if the syntax is wrong it should 
> have failed at xvda2 line , the very first line of jinja2 template. WHy it 
> failed at second line ? That's strange . What should be the correct way to 
> extract uuid that works in jinja2 template.
>
> Regards
> Sachin Kumar
>
> On Thursday, May 18, 2023 at 11:24:48 AM UTC+5:30 Dick Visser wrote:
>
>> On Thu, 18 May 2023 at 03:14, Sac Isilia  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 ansible-proje...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/52ff8092-399f-48ab-901a-228ce8c16c0cn%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>> -- 
>> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8cfbcb1e-047f-4ac9-b3ab-d277dc9b2411n%40googlegroups.com.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute 'xvdb'

2023-05-18 Thread Sac Isilia
Hi Team,

The standard way to access is - 
ansible_facts['device_links']['uuids']['xvdb'][0] . It works on existing 
rhel 7 machine but it fails there. Also if the syntax is wrong it should 
have failed at xvda2 line , the very first line of jinja2 template. WHy it 
failed at second line ? That's strange . What should be the correct way to 
extract uuid that works in jinja2 template.

Regards
Sachin Kumar

On Thursday, May 18, 2023 at 11:24:48 AM UTC+5:30 Dick Visser wrote:

> On Thu, 18 May 2023 at 03:14, Sac Isilia  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 ansible-proje...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/52ff8092-399f-48ab-901a-228ce8c16c0cn%40googlegroups.com
>>  
>> 
>> .
>>
> -- 
> 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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4e85a6ae-d96e-4afb-be36-52a0a92d6174n%40googlegroups.com.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute 'xvdb'

2023-05-17 Thread Dick Visser
On Thu, 18 May 2023 at 03:14, Sac Isilia 
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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/52ff8092-399f-48ab-901a-228ce8c16c0cn%40googlegroups.com
> 
> .
>
-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAF8BbLZPaZ7xzOFyevWMzV4P79H%2B38Nv9i1%2B0CFqM_PmHA9EDQ%40mail.gmail.com.


[ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute 'xvdb'

2023-05-17 Thread Sac Isilia
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\": {", 
"\"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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/52ff8092-399f-48ab-901a-228ce8c16c0cn%40googlegroups.com.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Freddie Eisa
I ran the following

Tasks:
   - debug: 
  var: ansible_ssh_host_key_ecdsa_public

Received this 

 {
"ansible_ssh_host_key_ecdsa_public": 
"E2VjZHNhLXNoYTItbmlzdHAyNTYIbmlzdHAyNTYAAABBBMj3Y7I/7ByqhoT22sBg2D0tUO8rCVQRTUQXyecCPVfXud9tnInwxXJUI8KKoIScw2YEKQuq8SPB46CE6ce6Bqw="


> On Jan 7, 2019, at 1:23 PM, Brian Coca  wrote:
> 
> so one of your hosts is not returning the fact for
> `ansible_ssh_host_key_ecdsa_public`, its not an issue with the
> template, but of getting the variable defined in the first place, the
> 'item' from the error will tell the first host host it is (add
> ignore_errors:yes and you'll see all the hosts that fail).
> 
> To avoid such issues you might want to use the |default() filter or
> check if the key exists before using it.
> 
> 
> --
> --
> Brian Coca
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/CACVha7coGzYr0OP80hc9SydkyoqYR3eygvuZuM_LP80ZzNcecA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/06B0600A-C8D5-4236-AFD3-045FC09E12C5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Brian Coca
so one of your hosts is not returning the fact for
`ansible_ssh_host_key_ecdsa_public`, its not an issue with the
template, but of getting the variable defined in the first place, the
'item' from the error will tell the first host host it is (add
ignore_errors:yes and you'll see all the hosts that fail).

To avoid such issues you might want to use the |default() filter or
check if the key exists before using it.


--
--
Brian Coca

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7coGzYr0OP80hc9SydkyoqYR3eygvuZuM_LP80ZzNcecA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Freddie Eisa
---
- hosts: all

  tasks:

   - debug: msg={{ hostvars[item]['ansible_ssh_host_key_ecdsa_public'] }}
 loop: '{{groups["all"]}}’

My playbook

> On Jan 7, 2019, at 12:57 PM, Brian Coca  wrote:
> 
> - debug: msg={{ hostvars[item]['ansible_ssh_host_key_ecdsa_public'] }}
>   loop: '{{groups["all"]}}'

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9F648737-14ED-4265-A490-43668A3DC030%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Freddie Eisa
"The task includes an option with an undefined variable. The error was: 
'ansible.vars.hostvars.HostVarsVars object' has no attribute 
'ansible_ssh_host_key_ecdsa_public'\n\nThe error appears to have been in 
'/home/feisa/ansible-linux/test_single_server.yml': line 6, column 6, but 
may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe 
offending line appears to be:\n\n\n   - debug: msg={{ 
hostvars[item]['ansible_ssh_host_key_ecdsa_public'] }}\n ^ here\nWe could 
be wrong, but this one looks like it might be an issue with\nmissing quotes.  
Always quote template expression brackets when they\nstart a value. For 
instance:\n\nwith_items:\n  - {{ foo }}\n\nShould be written as:\n\n
with_items:\n  - \"{{ foo }}\"\n"

> On Jan 7, 2019, at 12:57 PM, Brian Coca  wrote:
> 
> - debug: msg={{ hostvars[item]['ansible_ssh_host_key_ecdsa_public'] }}
>   loop: '{{groups["all"]}}'

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/A2F0871C-14DB-46BF-A3C4-5714DD99A76E%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Brian Coca
can you do this debug:

- debug: msg={{ hostvars[item]['ansible_ssh_host_key_ecdsa_public'] }}
   loop: '{{groups["all"]}}'


-- 
--
Brian Coca

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7fTQ-81eGLr7HVhUTpH%2BB4ch%3DaPDRpWxyL3JqdCo_%3D1cA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Freddie Eisa
Getting this now.

localhost]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 
'ansible.vars.hostvars.HostVarsVars object' has no attribute 
'ansible_ssh_host_key_ecdsa_public'"}

I debug the facts and see it

> On Jan 7, 2019, at 9:53 AM, Hugo Gonzalez  wrote:
> 
> {% for host in groups['all'] %} 
> {{ hostvars[host]['ansible_ssh_host_key_ecdsa_public'] }}  
> {% endfor %}
> 
> 

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/D5570D35-1D6E-46D5-A3DC-6FC2DEA69269%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Hugo Gonzalez

Can you try removing the "

ignore_errors:yes
"you had before? Maybe something in failing in the facts gathering and, 
naturally, the variables did not get populated.



Here's the full playbook and template I used to test (this does not even 
need to escalate privileges):


---
- hosts: all

  tasks:

    - name: Render the known_hosts file locally
  template:
    src: template.j2
    dest: /tmp/known_hosts
  delegate_to: localhost
  run_once: true

    - name: Copy the rendered file to all the nodes
  copy:
    src: /tmp/known_hosts
    dest: /tmp


Template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_ssh_host_key_ecdsa_public'] }}
{% endfor %}





On 1/7/19 10:30 AM, Freddie Eisa wrote:

Same error, can you send full playbook details over you are testing?

localhost]: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars object' 
has no attribute 'ansible_ssh_host_key_ecdsa_public'"}


On Jan 4, 2019, at 11:47 AM, Hugo Gonzalez > wrote:




--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3eaa0eef-e547-f758-5c96-55276770f967%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Freddie Eisa
Same error, can you send full playbook details over you are testing?

localhost]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 
'ansible.vars.hostvars.HostVarsVars object' has no attribute 
'ansible_ssh_host_key_ecdsa_public'"}

> On Jan 4, 2019, at 11:47 AM, Hugo Gonzalez  wrote:
> 
> 
>> template:
>> 
>> {% for host in groups['all'] %} 
>> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}  
>> {% endfor %}
>> 
>> 
> This template also works for me, and the keys are different. So you might 
> want to try it:
> 
> {% for host in groups['all'] %}
> {{ hostvars[host]['ansible_ssh_host_key_ecdsa_public'] }}
> {% endfor %}
> 
> 
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/434eb480-74f4-5d68-f97c-fc2c9469b412%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/42D07B3B-1AFA-4FA4-8708-2BDE4C635750%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Freddie Eisa
No luck so far 

> On Jan 4, 2019, at 11:47 AM, Hugo Gonzalez  wrote:
> 
> 
>> template:
>> 
>> {% for host in groups['all'] %} 
>> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}  
>> {% endfor %}
>> 
>> 
> This template also works for me, and the keys are different. So you might 
> want to try it:
> 
> {% for host in groups['all'] %}
> {{ hostvars[host]['ansible_ssh_host_key_ecdsa_public'] }}
> {% endfor %}
> 
> 
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/434eb480-74f4-5d68-f97c-fc2c9469b412%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/099D0DBE-619D-4C66-BEC1-53C5880C15D5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-07 Thread Freddie Eisa
Ill test today

> On Jan 4, 2019, at 11:47 AM, Hugo Gonzalez  wrote:
> 
> 
>> template:
>> 
>> {% for host in groups['all'] %} 
>> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}  
>> {% endfor %}
>> 
>> 
> This template also works for me, and the keys are different. So you might 
> want to try it:
> 
> {% for host in groups['all'] %}
> {{ hostvars[host]['ansible_ssh_host_key_ecdsa_public'] }}
> {% endfor %}
> 
> 
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/434eb480-74f4-5d68-f97c-fc2c9469b412%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ECCF2DA7-3824-4D8C-A37C-B20616853693%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-04 Thread Hugo Gonzalez



template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
{% endfor %}

This template also works for me, and the keys are different. So you 
might want to try it:


{% for host in groups['all'] %}
{{ hostvars[host]['ansible_ssh_host_key_ecdsa_public'] }}
{% endfor %}


--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/434eb480-74f4-5d68-f97c-fc2c9469b412%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-04 Thread Hugo Gonzalez

Hello Freddie

On 1/3/19 5:23 PM, Freddie Eisa wrote:

What version are you running? The linux host is centos7.6

Ansible is 2.5.1, managed hosts are two Centos 7.6 cloud servers in my 
tests.



I tried the following:

- gather facts (automatic)

- locally render the template *on the controlling node*, once

- push the templated file to the managed hosts.


Curious if this will work for you:


template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
{% endfor %}

playbook:

---
- hosts: all

  tasks:
    - name: Render the known_hosts file locally
  template:
    src: template.j2
    dest: /tmp/known_hosts
  delegate_to: localhost
  run_once: true

    - name: Copy the rendered file to all the nodes
  copy:
    src: /tmp/known_hosts
    dest: /tmp


---


Still not getting the error you're getting, except when trying to use 
the variable as *ansible_*ssh_host_key_ecdsa_public and that's not 
consistent, so I may be running into a completely different issue.



--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/65568060-fa3f-f900-625c-a8f07f63440e%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Freddie Eisa
I removed it with the same issue

{% for host in groups['all'] %}
   {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
{% endfor %}

> On Jan 3, 2019, at 4:38 PM, Karl Auer  wrote:
> 
> Your version has double quotes around the second line. The known working 
> version does not. Could that be an issue?
> 
> Regards, K.
> 
> On Fri, Jan 4, 2019 at 10:20 AM Freddie Eisa  > wrote:
> I just ran the same thing you ddi with the same issue I had. 
> 
>> On Jan 3, 2019, at 4:06 PM, Hugo Gonzalez > > wrote:
>> 
>> Got to be something else. Are these linux hosts?
>> 
>> I tried this and it works:
>> 
>> playbook:
>> 
>> ---
>> - hosts: all
>> 
>>   tasks:
>> - template:
>> src: template.j2
>> dest: /tmp/knownhosts
>> 
>> 
>> 
>> template:
>> 
>> {% for host in groups['all'] %} 
>> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}  
>> {% endfor %}
>> 
>> --
>> 
>> I suggest you run the setup module on your managed hosts and see the 
>> structure of the facts on your hosts then, and see if the host keys are 
>> there with that name.
>> 
>> 
>> 
>> Hugo G. 
>> 
>> 
>> 
>> On 1/3/19 4:33 PM, Freddie Eisa wrote:
>>> This is what I’m running 
>>> 
>>> My role
>>> - name: Template Knownhosts
>>>   template: src=./ssh_key.j2 dest=/tmp/temp.conf
>>> 
>>> My template 
>>> {% for host in groups['all'] %}
>>>"{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
>>> {% endfor %}
>>> 
>>> My playbook
>>> 
>>> ---
>>> - name: Centos 7 Servers
>>>   hosts: servers_all
>>>   gather_facts: True
>>>   ignore_errors: yes
>>>   roles:
>>>- linux-role
 
 -- 
 HUGO F. GONZALEZ
 SENIOR CONSULTANT
 Red Hat LATAM 
  
 
 -- 
 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 post to this group, send email to ansible-project@googlegroups.com 
 .
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com
  
 .
 For more options, visit https://groups.google.com/d/optout 
 .
>>> 
>>> -- 
>>> 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 post to this group, send email to ansible-project@googlegroups.com 
>>> .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com
>>>  
>>> .
>>> For more options, visit https://groups.google.com/d/optout 
>>> .
>> -- 
>> HUGO F. GONZALEZ
>> SENIOR CONSULTANT
>> Red Hat LATAM 
>>  
>> 
>> -- 
>> 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 post to this group, send email to ansible-project@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> 
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> 

Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Karl Auer
Your version has double quotes around the second line. The known working
version does not. Could that be an issue?

Regards, K.

On Fri, Jan 4, 2019 at 10:20 AM Freddie Eisa  wrote:

> I just ran the same thing you ddi with the same issue I had.
>
> On Jan 3, 2019, at 4:06 PM, Hugo Gonzalez  wrote:
>
> Got to be something else. Are these linux hosts?
>
> I tried this and it works:
>
> playbook:
>
> ---
> - hosts: all
>
>   tasks:
> - template:
> src: template.j2
> dest: /tmp/knownhosts
>
> 
>
> template:
>
> {% for host in groups['all'] %}
> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
> {% endfor %}
>
> --
>
> I suggest you run the setup module on your managed hosts and see the
> structure of the facts on your hosts then, and see if the host keys are
> there with that name.
>
>
> Hugo G.
>
>
> On 1/3/19 4:33 PM, Freddie Eisa wrote:
>
> This is what I’m running
>
> My role
> - name: Template Knownhosts
>   template: src=./ssh_key.j2 dest=/tmp/temp.conf
>
> My template
> {% for host in groups['all'] %}
>"{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
> {% endfor %}
>
> My playbook
>
> ---
> - name: Centos 7 Servers
>   hosts: servers_all
>   gather_facts: True
>   ignore_errors: yes
>   roles:
>- linux-role
>
>
> --
> HUGO F. GONZALEZ
>
> SENIOR CONSULTANT
> Red Hat LATAM 
> 
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> HUGO F. GONZALEZ
>
> SENIOR CONSULTANT
> Red Hat LATAM 
> 
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/A7231E7C-CA93-44B8-BCCD-A0862C691B18%40gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Karl Auer

Email  : ka...@2pisoftware.com
Website: http://2pisoftware.com

GPG/PGP : 958A 2647 6C44 D376 3D63 86A5 FFB2 20BC 0257 5816
Previous: F0AB 6C70 A49D 1927 6E05 81E7 AD95 268F 2AB6 40EA

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2B%2BT08RcnnB79%2BTjdZXZxh%2BTHYTbxy9WmdLBHuK5tsmq7dT0sQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Freddie Eisa
What version are you running? The linux host is centos7.6

Verified in my facts

"ansible_ssh_host_key_ecdsa_public": 
"E2VjZHNhLXNoYTItbmlzdHAyNTYIbmlzdHAyNTYAAABBBGpMZqjhIzo6gGjz4eczxnatrAgmPxdWVYf0zY29MDngkKuOzjB0bMrR5sQm1X6leGgYowv3wNloWOZVbhwPU2A=",
 

> On Jan 3, 2019, at 4:06 PM, Hugo Gonzalez  wrote:
> 
> Got to be something else. Are these linux hosts?
> 
> I tried this and it works:
> 
> playbook:
> 
> ---
> - hosts: all
> 
>   tasks:
> - template:
> src: template.j2
> dest: /tmp/knownhosts
> 
> 
> 
> template:
> 
> {% for host in groups['all'] %} 
> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}  
> {% endfor %}
> 
> --
> 
> I suggest you run the setup module on your managed hosts and see the 
> structure of the facts on your hosts then, and see if the host keys are there 
> with that name.
> 
> 
> 
> Hugo G. 
> 
> 
> 
> On 1/3/19 4:33 PM, Freddie Eisa wrote:
>> This is what I’m running 
>> 
>> My role
>> - name: Template Knownhosts
>>   template: src=./ssh_key.j2 dest=/tmp/temp.conf
>> 
>> My template 
>> {% for host in groups['all'] %}
>>"{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
>> {% endfor %}
>> 
>> My playbook
>> 
>> ---
>> - name: Centos 7 Servers
>>   hosts: servers_all
>>   gather_facts: True
>>   ignore_errors: yes
>>   roles:
>>- linux-role
>>> 
>>> -- 
>>> HUGO F. GONZALEZ
>>> SENIOR CONSULTANT
>>> Red Hat LATAM 
>>>  
>>> 
>>> -- 
>>> 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 post to this group, send email to ansible-project@googlegroups.com 
>>> .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com
>>>  
>>> .
>>> For more options, visit https://groups.google.com/d/optout 
>>> .
>> 
>> -- 
>> 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 post to this group, send email to ansible-project@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> -- 
> HUGO F. GONZALEZ
> SENIOR CONSULTANT
> Red Hat LATAM 
>  
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/E1081AAA-47FF-4265-A5F9-93FE4835A79B%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Freddie Eisa
I just ran the same thing you ddi with the same issue I had. 

> On Jan 3, 2019, at 4:06 PM, Hugo Gonzalez  wrote:
> 
> Got to be something else. Are these linux hosts?
> 
> I tried this and it works:
> 
> playbook:
> 
> ---
> - hosts: all
> 
>   tasks:
> - template:
> src: template.j2
> dest: /tmp/knownhosts
> 
> 
> 
> template:
> 
> {% for host in groups['all'] %} 
> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}  
> {% endfor %}
> 
> --
> 
> I suggest you run the setup module on your managed hosts and see the 
> structure of the facts on your hosts then, and see if the host keys are there 
> with that name.
> 
> 
> 
> Hugo G. 
> 
> 
> 
> On 1/3/19 4:33 PM, Freddie Eisa wrote:
>> This is what I’m running 
>> 
>> My role
>> - name: Template Knownhosts
>>   template: src=./ssh_key.j2 dest=/tmp/temp.conf
>> 
>> My template 
>> {% for host in groups['all'] %}
>>"{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
>> {% endfor %}
>> 
>> My playbook
>> 
>> ---
>> - name: Centos 7 Servers
>>   hosts: servers_all
>>   gather_facts: True
>>   ignore_errors: yes
>>   roles:
>>- linux-role
>>> 
>>> -- 
>>> HUGO F. GONZALEZ
>>> SENIOR CONSULTANT
>>> Red Hat LATAM 
>>>  
>>> 
>>> -- 
>>> 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 post to this group, send email to ansible-project@googlegroups.com 
>>> .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com
>>>  
>>> .
>>> For more options, visit https://groups.google.com/d/optout 
>>> .
>> 
>> -- 
>> 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 post to this group, send email to ansible-project@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> -- 
> HUGO F. GONZALEZ
> SENIOR CONSULTANT
> Red Hat LATAM 
>  
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/A7231E7C-CA93-44B8-BCCD-A0862C691B18%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Freddie Eisa
They keys are there in facts

> On Jan 3, 2019, at 4:06 PM, Hugo Gonzalez  wrote:
> 
> Got to be something else. Are these linux hosts?
> 
> I tried this and it works:
> 
> playbook:
> 
> ---
> - hosts: all
> 
>   tasks:
> - template:
> src: template.j2
> dest: /tmp/knownhosts
> 
> 
> 
> template:
> 
> {% for host in groups['all'] %} 
> {{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}  
> {% endfor %}
> 
> --
> 
> I suggest you run the setup module on your managed hosts and see the 
> structure of the facts on your hosts then, and see if the host keys are there 
> with that name.
> 
> 
> 
> Hugo G. 
> 
> 
> 
> On 1/3/19 4:33 PM, Freddie Eisa wrote:
>> This is what I’m running 
>> 
>> My role
>> - name: Template Knownhosts
>>   template: src=./ssh_key.j2 dest=/tmp/temp.conf
>> 
>> My template 
>> {% for host in groups['all'] %}
>>"{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
>> {% endfor %}
>> 
>> My playbook
>> 
>> ---
>> - name: Centos 7 Servers
>>   hosts: servers_all
>>   gather_facts: True
>>   ignore_errors: yes
>>   roles:
>>- linux-role
>>> 
>>> -- 
>>> HUGO F. GONZALEZ
>>> SENIOR CONSULTANT
>>> Red Hat LATAM 
>>>  
>>> 
>>> -- 
>>> 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 post to this group, send email to ansible-project@googlegroups.com 
>>> .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com
>>>  
>>> .
>>> For more options, visit https://groups.google.com/d/optout 
>>> .
>> 
>> -- 
>> 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 post to this group, send email to ansible-project@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
> -- 
> HUGO F. GONZALEZ
> SENIOR CONSULTANT
> Red Hat LATAM 
>  
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/C53CF09D-DF49-41A3-8585-4911AC3A1264%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Hugo Gonzalez

Got to be something else. Are these linux hosts?

I tried this and it works:

playbook:

---
- hosts: all

  tasks:
    - template:
    src: template.j2
    dest: /tmp/knownhosts



template:

{% for host in groups['all'] %}
{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}
{% endfor %}

--

I suggest you run the setup module on your managed hosts and see the 
structure of the facts on your hosts then, and see if the host keys are 
there with that name.



Hugo G.


On 1/3/19 4:33 PM, Freddie Eisa wrote:

This is what I’m running

My role
- name: Template Knownhosts
template: src=./ssh_key.j2 dest=/tmp/temp.conf

My template
{% for host in groups['all'] %}
   "{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
{% endfor %}

My playbook

---
- name:Centos 7Servers
hosts:servers_all
gather_facts:True
ignore_errors:yes
roles:
   - linux-role


--
HUGO F.GONZALEZ

SENIOR CONSULTANT

Red HatLATAM 



--
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 toansible-project+unsubscr...@googlegroups.com 
.
To post to this group, send email toansible-proj...@googlegroups.com 
.
To view this discussion on the web 
visithttps://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com 
.

For more options, visithttps://groups.google.com/d/optout.


--
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 post to this group, send email to ansible-project@googlegroups.com 
.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com 
.

For more options, visit https://groups.google.com/d/optout.

--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8feca239-8c6b-4ef8-8331-4d26489f125c%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Freddie Eisa
This is what I’m running 

My role
- name: Template Knownhosts
  template: src=./ssh_key.j2 dest=/tmp/temp.conf

My template 
{% for host in groups['all'] %}
   "{{ hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }}"
{% endfor %}

My playbook

---
- name: Centos 7 Servers
  hosts: servers_all
  gather_facts: True
  ignore_errors: yes
  roles:
   - linux-role

> On Jan 3, 2019, at 3:31 PM, Hugo Gonzalez  wrote:
> 
> 
> On 1/3/19 4:26 PM, Freddie Eisa wrote:
>> I had tried but still receive 
>> 
>> fatal: [server]: FAILED! => {"changed": false, "msg": 
>> "AnsibleUndefinedVariable: 'dict object' has no attribute 
>> 'ssh_host_key_ecdsa_public'"}
>> 
> Please post the play you're using, or at least the relevant task and template.
> 
>>> This works for me and prints the key.---
>>> - hosts: all
>>> 
>>>   tasks:
>>> - debug:
>>> msg: "{% for host in groups['all'] %} {{ 
>>> hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }} {% endfor 
>>> %}"
>>> 
>>> 
> -- 
> HUGO F. GONZALEZ
> SENIOR CONSULTANT
> Red Hat LATAM 
>  
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4B57DC00-7EAD-4209-97FA-C75F30038649%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Hugo Gonzalez


On 1/3/19 4:26 PM, Freddie Eisa wrote:

I had tried but still receive

fatal: [server]: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'dict object' has no attribute 
'ssh_host_key_ecdsa_public'"}


Please post the play you're using, or at least the relevant task and 
template.



This works for me and prints the key.---
- hosts: all

  tasks:
    - debug:
    msg: "{% for host in groups['all'] %} {{ 
hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }} {% 
endfor %}"




--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/51fe343a-0562-0849-9161-4a0d04366503%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Freddie Eisa
I had tried but still receive 

fatal: [server]: FAILED! => {"changed": false, "msg": 
"AnsibleUndefinedVariable: 'dict object' has no attribute 
'ssh_host_key_ecdsa_public'"}

> On Jan 3, 2019, at 3:23 PM, Hugo Gonzalez  wrote:
> 
> 
> 
> On 1/3/19 3:34 PM, Freddie Eisa wrote:
>> So it depends on the host and how they are named and was really a test case. 
>> The one I’m really concerned about is this one now 
>> 
>> 
>> {% for host in groups['servers_production'] %}
>>{{ hostvars[host]['ssh_host_key_ecdsa_public'] }}
>> {% endfor %}
> 
> I think you mean:  
> hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public']
> 
> This works for me and prints the key.---
> - hosts: all
> 
>   tasks:
> - debug:
> msg: "{% for host in groups['all'] %} {{ 
> hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }} {% endfor %}"
> 
> 
> Hugo G.
> 
> 
> 
> 
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/d10c2a5d-48dd-dd67-d85e-4cd3a29d819d%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5AF458C6-F964-4EE2-A61F-33F76510D6CE%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Hugo Gonzalez


On 1/3/19 3:34 PM, Freddie Eisa wrote:
So it depends on the host and how they are named and was really a test 
case. The one I’m really concerned about is this one now



{% for host in groups['servers_production'] %}
{{ hostvars[host]['ssh_host_key_ecdsa_public'] }}
{% endfor %}


I think you mean: 
hostvars[host]*['ansible_facts']*['ssh_host_key_ecdsa_public']


This works for me and prints the key.---
- hosts: all

  tasks:
    - debug:
    msg: "{% for host in groups['all'] %} {{ 
hostvars[host]['ansible_facts']['ssh_host_key_ecdsa_public'] }} {% 
endfor %}"



Hugo G.



--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d10c2a5d-48dd-dd67-d85e-4cd3a29d819d%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Freddie Eisa
So it depends on the host and how they are named and was really a test case. 
The one I’m really concerned about is this one now 


{% for host in groups['servers_production'] %}
   {{ hostvars[host]['ssh_host_key_ecdsa_public'] }}
{% endfor %}

> On Jan 3, 2019, at 2:31 PM, Hugo Gonzalez  wrote:
> 
> Hello Freddie,
> 
> 
> On 1/3/19 12:04 PM, Freddie Eisa wrote:
>> {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no 
>> attribute 'eth0'"}
>> 
>> 
> How do you know what to look for in ansible_facts? Run the setup module 
> against your managed hosts and see what the facts look like.
> 
> I have this on a node of mine:
> 
>   "ansible_facts": {
> ...,
> 
>  "ansible_default_ipv4": {
> "address": "", 
> "alias": "eth0", 
> "broadcast": "", 
> "gateway": "", 
> "interface": "eth0", 
> "macaddress": "X", 
> "mtu": 1500, 
> "netmask": "255.255.248.0", 
> "network": "XXX", 
> "type": "ether"
> }, 
> }
> 
> 
> I don't see any hostvars[host]['ansible_facts']['eth0']['ipv4']['address'] 
> 
> Try  $ ansible  -m  setup and examine the output to see how you 
> should look for eth0's IP address.
> 
> 
> 
> Cheers,
> 
> 
> 
> Hugo
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> HUGO F. GONZALEZ
> SENIOR CONSULTANT
> Red Hat LATAM 
>  
> 
> -- 
> 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 post to this group, send email to ansible-project@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/4473f03c-a4f0-f89c-5d92-77b2cf85ba01%40redhat.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9A28E9E8-3649-4294-AA53-C3795A1A1A7B%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Hugo Gonzalez

Hello Freddie,


On 1/3/19 12:04 PM, Freddie Eisa wrote:


{"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has 
no attribute 'eth0'"}



How do you know what to look for in ansible_facts? Run the setup module 
against your managed hosts and see what the facts look like.


I have this on a node of mine:

  "ansible_facts": {
...,

 "ansible_default_ipv4": {
    "address": "",
    "alias": "eth0",
    "broadcast": "",
    "gateway": "",
    "interface": "eth0",
    "macaddress": "X",
    "mtu": 1500,
    "netmask": "255.255.248.0",
    "network": "XXX",
    "type": "ether"
    },
}


I don't see any hostvars[host]['ansible_facts']['eth0']['ipv4']['address']

Try  $ ansible  -m  setup and examine the output to see how 
you should look for eth0's IP address.



Cheers,


Hugo





--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 



--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4473f03c-a4f0-f89c-5d92-77b2cf85ba01%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute

2019-01-03 Thread Freddie Eisa
SUMMARY

jinja2 template issues with hostvars
ISSUE TYPE
   
   - Bug Report

COMPONENT NAME

jinja2 template
ANSIBLE VERSION

ansible 2.7.2
config file = /home/feisa/ansible-linux/ansible.cfg
configured module search path = [u'/home/feisa/ansible-linux/library']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 
(Red Hat 4.8.5-36)]
CONFIGURATION

jinja2 template

{% for host in groups['servers_production'] %}
   {{ hostvars[host]['ansible_facts']['eth0']['ipv4']['address'] }}
{% endfor %}

- name: Template Knownhosts
  template: src=./ssh.j2 dest=/tmp/temp.conf

OS / ENVIRONMENT

Centos 7.6
STEPS TO REPRODUCE

run normal ansible playblook
EXPECTED RESULTS

playbook runs succesfully
ACTUAL RESULTS

{"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no 
attribute 'eth0'"}

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9c75ec4f-e9a8-4140-9817-059fa0b0723c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] AnsibleUndefinedVariable: 'dict object' has no attribute u'ansible_eth1

2018-04-24 Thread Alisson Medeiros
*System:*

Vagrant with ubuntu xenial 64 box


*Task:*

TASK [memcached : Copying over config.json files for services]


*/usr/local/share/kolla-ansible/ansible/roles/memcached/tasks/config.yml*
- name: Ensuring config directories exist
  file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
recurse: yes
  with_items:
- "memcached"

- name: Copying over config.json files for services
  template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
  register: memcached_config_json
  with_items:
- "memcached"
  notify: Restart memcached container

- name: Check memcached container
  vars:
service: "{{ memcached_services.memcached }}"
  kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
volumes: "{{ service.volumes }}"
  register: check_memcached_container
  when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
- action != "config"
  notify: Restart memcached container


*Ful error:*

TASK [memcached : Copying over config.json files for services] 
*
task path: /usr/local/share/kolla-ansible/ansible/roles/memcached/tasks/
config.yml:10
 ESTABLISH LOCAL CONNECTION FOR USER: root
 EXEC /bin/sh -c 'echo ~ && sleep 0'
 EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/home/vagrant/.ansible/tmp/ansible-tmp-1524554119.15-234223887769910 `" && 
echo ansible-tmp-1524554119.15-234223887769910="` echo 
/home/vagrant/.ansible/tmp/ansible-tmp-1524554119.15-234223887769910 `" ) 
&& sleep 0'
 EXEC /bin/sh -c 'rm -f -r 
/home/vagrant/.ansible/tmp/ansible-tmp-1524554119.15-234223887769910/ > 
/dev/null 2>&1 && sleep 0'
failed: [localhost] (item=memcached) => {
"changed": false, 
"item": "memcached", 
"msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 
u'ansible_eth1'"
}
to retry, use: --limit @/usr/local/share/kolla-ansible/ansible/site.
retry

PLAY RECAP 
*
localhost  : ok=4changed=0unreachable=0failed=1

Command failed ansible-playbook -i /usr/local/share/kolla-ansible/ansible/
inventory/all-in-one -e @/etc/kolla/globals.yml -e @/etc/kolla/passwords.yml 
-e CONFIG_DIR=/etc/kolla  -e action=deploy /usr/local/share/kolla-ansible/
ansible/site.yml  --verbose --verbose --verbose --verbose

*Playbook /usr/local/share/kolla-ansible/ansible/inventory/all-in-one*
# These initial groups are the only groups required to be modified. The
# additional groups are for more control of the environment.
[control]
localhost   ansible_connection=local

[network]
localhost   ansible_connection=local

[compute]
localhost   ansible_connection=local

[storage]
localhost   ansible_connection=local

[monitoring]
localhost   ansible_connection=local

[deployment]
localhost   ansible_connection=local

# You can explicitly specify which hosts run each project by updating the
# groups in the sections below. Common services are grouped together.
[chrony-server:children]
haproxy

[chrony:children]
network
compute
storage
monitoring

[collectd:children]
compute

[baremetal:children]
control

[grafana:children]
monitoring

[etcd:children]
control
compute

[karbor:children]
control

[kibana:children]
control

[telegraf:children]
compute
control
monitoring
network
storage

[elasticsearch:children]
control

[haproxy:children]
network

[hyperv]
#hyperv_host

[hyperv:vars]
#ansible_user=user
#ansible_password=password
#ansible_port=5986
#ansible_connection=winrm
#ansible_winrm_server_cert_validation=ignore

[mariadb:children]
control

[rabbitmq:children]
control

[outward-rabbitmq:children]
control

[qdrouterd:children]
control

[mongodb:children]
control

[keystone:children]
control

[glance:children]
control

[nova:children]
control

[neutron:children]
network

[openvswitch:children]
network
compute
manila-share

[opendaylight:children]
network

[cinder:children]
control

[cloudkitty:children]
control

[freezer:children]
control

[memcached:children]
control

[horizon:children]
control

[swift:children]
control

[barbican:children]
control

[heat:children]
control

[murano:children]
control

[ceph:children]
control

[ironic:children]
control

[influxdb:children]
monitoring

[magnum:children]
control

[sahara:children]
control

[solum:children]
control

[mistral:children]
control

[manila:children]
control

[panko:children]
control

[gnocchi:children]
control

[ceilometer:children]
control

[aodh:children]
control

[congress:children]
control

[tacker:children]
control

# Tempest
[tempest:children]
control

[senlin:children]
control

[vmtp:children]
control

[trove:children]
control

[watcher:children]
control

[rally:children]
control

[searchlight:children]
control

[octavia:children]
control

[designate:children]
control

[placement:children]
control


[ansible-project] "AnsibleUndefinedVariable: 'dict object' has no attribute

2018-03-09 Thread jaychandran subramanian

>
>
>
> [WARNING]: log file at /var/log/ansible.log is not writeable and we cannot 
> create it, aborting
> ansible 2.4.3.0
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = [u'/usr/share/my_modules']
>   ansible python module location = 
> /usr/local/lib/python2.7/dist-packages/ansible
>   executable location = /usr/local/bin/ansible
>   python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 
> 20160609]
>
> --
>
# This is the file that generate .cfg file from template. 
# /etc/ansible/leaf_bgp/tasks/cfg_generator.yaml  
# this file will be called form /etc/ansible/sudo ansible-playbook 
spine.yml - 

> ---
>  - name: Clear gathered facts from all currently targeted hosts
>meta: refresh_inventory
>
>  - name: Generating LEAF-BGP configuration
>template:
>   src="/etc/ansible/leaf_bgp/templates/leaf_bgp_template.j2"
>   dest=/etc/ansible/leaf_bgp/files/{{item.host_ip}}_leaf_bgp.cfg
>when:
>   - item.host_ip |string  in 
> hostvars[inventory_hostname].inventory_hostname
>with_items:
>  - "{{ leaf_bgp }}"
> # - "{{ all_vars }}"
>
> 
>
#This file is /etc/ansible/bgp_leaf/defaults/main.yaml
# I am trying to access these variables for all routers of junos
#these are common variables for all routers  

> ---
> # defaults file for leaf_bgp
> all_vars:
>   [
>   local_as : '65111',
>   peer_as : '65101',
>   evpn_as : '65100',
>   spine_lo0 : '172.21.0.11',
>   ]
>

# I tried lot of different ways like
# Still not able to access the variables from this defaults/main.yaml file 
# I am getting same error as "AnsibleUndefinedVariable: 'dict object' has 
no attribute 

>
> ---
>
# This is /etc/ansible/bgp_leaf/vars/main.yaml
# When i have all variables here my script is running fine. It is 
generating .cfg file. But I want to access some variable from 
/defaults/main.yaml 

> #Vars file
> leaf_bgp:  
>  
>   
> 
>#4_Member Leaf TOA  
>
>   
> 
>- {'host_ip' : '135.182.175.7',
> 
>   'host_name' : 'something',  
>   
>   'loopback0' : '172.21.0.1',  
>
>   
> 
>   'spine_neighbor' : '10.11.1.1',  
>
>   'spinev6_neighbor' : 'Something',
>   
>   
> 
>  } 
>
> ---
>
>
> The error is  "msg": "AnsibleUndefinedVariable: 'dict object' has no 
> attribute 'local_as'"
>
> Please solve
>
> I tried changing differnt formats  

#This file is /etc/ansible/bgp_leaf/defaults/main.yaml
# I am trying to access these variables for all routers of junos
#these are common variables for all routers  
---
# defaults file for leaf_bgp
local_as : '65111',
peer_as : '65101',
evpn_as : '65100',
spine_lo0 : '172.21.0.11',
---
#This file is /etc/ansible/bgp_leaf/defaults/main.yaml
# I am trying to access these variables for all routers of junos
#these are common variables for all routers  
---
# defaults file for leaf_bgp
{
 'local_as' : '65111',
 'peer_as' : '65101',
 'evpn_as' : '65100',
 'spine_lo0' : '172.21.0.11',
}
-
#This file is /etc/ansible/bgp_leaf/defaults/main.yaml
# I am trying to access these variables for all routers of junos
#these are common variables for all routers  
---
# defaults file for leaf_bgp
'local_as' : '65111',
'peer_as' : '65101',
'evpn_as' : '65100',
'spine_lo0' : '172.21.0.11',
---

Please do the needful 

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web