The stat module does not have a return key of stdout_lines. For a list of
data that is returned from the stat module please reference this page here
<https://docs.ansible.com/ansible/latest/modules/stat_module.html#return-values>
.
On Monday, February 18, 2019 at 2:58:11 AM UTC-6, Adelmo Silva wrote:
>
> Good Morning
> I need to send to a text file a message that appears in debug msg after a
> check if a directory exists. Follow Playbook below. But it is giving error
> in the recording of the file.
>
> This is my Playbook
>
> hosts: teste
> become: yes
> become_user: root
> become_method: sudo
> gather_facts: yes
>
> tasks:
>
> * name: Verificando Diretórios
> stat:
> path: /etc/teste_path/
> register: path
> * debug:
> msg: "Diretório Ok"
> when: path.stat.isdir is defined and path.stat.isdir
> * debug:
> msg: "Diretório Não existe"
> when: path.stat.exists == False
> * debug: var=path.stdout_lines
> * name: Gravando Valores
> local_action: lineinfile path=/root/find_path.txt
> line={{path.stdout_lines}}; create=yes
>
>
> And results with errors:
>
> ASK [Gravando Valores]
> *************************************************************************************************************************************************************************************
> fatal: [10.0.10.117]: FAILED! => {"msg": "The task includes an option with
> an undefined variable. The error was: 'dict object' has no attribute
> 'stdout_lines'\n\nThe error appears to have been in
> '/root/Ansible/Playbooks/find_path.yaml': line 24, column 5, but may\nbe
> elsewhere in the file depending on the exact syntax problem.\n\nThe
> offending line appears to be:\n\n\n - name: Gravando Valores\n ^
> here\n\nexception type: <class
> 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no
> attribute 'stdout_lines'"}
> fatal: [10.0.10.122]: FAILED! => {"msg": "The task includes an option with
> an undefined variable. The error was: 'dict object' has no attribute
> 'stdout_lines'\n\nThe error appears to have been in
> '/root/Ansible/Playbooks/find_path.yaml': line 24, column 5, but may\nbe
> elsewhere in the file depending on the exact syntax problem.\n\nThe
> offending line appears to be:\n\n\n - name: Gravando Valores\n ^
> here\n\nexception type: <class
> 'ansible.errors.AnsibleUndefinedVariable'>\nexception: 'dict object' has no
> attribute 'stdout_lines'"}
> to retry, use: --limit @/root/Ansible/Playbooks/find_path.retry
>
>
>
> Thansk for your attention.
>
>
>
>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/9a5316e9-c172-4ccb-b0bb-30b7e1a4f4fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.