"What is Ansible?" post - giving me errors

URL: What is Ansible? A Tool to Automate Parts of Your Job

I’m attempting the “make an Ansible playbook” section with a modiffication to NOT install docker; Simply trying to capture the output of an echo command. However, I get an error which might be syntax. Has anyone completed this particular New article’s tutorial? Have you used Ansible’s “debug” feature successfully to output a variable?

@Idris Olubisi - I think I have identified my problem.

The presentation of the YAML code in the article’s code blocks DOES NOT faithfully render the syntax. By this I mean the indentation which YAML requires is not visually obvious. I will attempt to demonstrate my meaning below:

the faulty provided code:

- name: Test Docker with hello world example
become: true
shell: docker run hello-world
register: hello_world_output

- name: Show output of hello word example
debug: #use debug module
msg: "Container Output: {{hello_world_output.stdout}}"`

ERROR: Every line is fully left-justified

the valid code:

- name: Test Docker with hello world example
  become: true
  shell: docker run hello-world
  register: hello_world_output

- name: Show output of hello word example
  debug: #use debug module
    msg: "Container Output: {{hello_world_output.stdout}}"

This is a snip from the sample code, so as-is it is not going to be accepted by the ansible-playbook processor; it just shows the proper indentation.

I hope this helps anyone else who attempts to follow that article. Soon, I will try to implement it as-is in an environment where I can freely install docker!

Happy coding!