Define and Print Variables With Ansible

This blog post will show you how to define a variable and print it using two methods inside an Ansible playbook.

Debug

In the following playbook, we will define a variable called test and print it using two methods, the first is using the var option and the second is using msg.

---
- name: playbook
  hosts: localhost
  vars:
    test: hello
  tasks:
    - name: dubug option 1
      debug: var=test
      
    - name: dubug option 2
      debug:
        msg: "{{ test }}"

If you like this post make sure you visit our Ansible category page.

Processing…
Success! You're on the list.

Posted

in

by