Debug Module Returns "Hello, World!" when a message is specified.

18 views
Skip to first unread message

Philip Gregory

unread,
Jan 12, 2018, 10:54:22 PM1/12/18
to Ansible Project
Using Ansible 2.4.2.0 on Ubuntu 16.04, I try running a plaubook with the following:

- name: Create repo line in Ubuntu/Debian
command: bash -c "echo \"deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable\" "
register: docker_repo_line
when:
ansible_distribution == 'Debian'
or
ansible_distribution == 'Ubuntu'
- debug:
msg: "{{ docker_repo_line.stdout }}"
when:
ansible_distribution == 'Debian'
or
ansible_distribution == 'Ubuntu'
- name: Add Docker Repo on Ubuntu/Debian
apt_repository:
repo: "{{ docker_repo_line.stdout }}"
state: present
when:
ansible_distribution == 'Debian'
or
ansible_distribution == 'Ubuntu'


However, the Debig Module set the message as "hello, world" when I run the command. Looking at the module documentation, this is the default if no msg is specified. However, I do I have line for hte message. Am I missing something here?


J Hawkesworth

unread,
Jan 14, 2018, 3:41:22 AM1/14/18
to Ansible Project
My guess is all the module results are contained in a key called 'results' within the var that you registered.

Try this

- debug:
var: "{{ docker_repo_line }}"

I suspect that the bit you want is in
- debug:
msg: "{{ docker_repo_line.results.stdout }}"

But try inspecting the whole of the var. If there is a lot of output, use something like Jsonlint.com to pretty print the json so that you can get a clearer idea of what is being returned.

Hope this helps,

Jon

Reply all
Reply to author
Forward
0 new messages