Ansible modules parameter syntax

116 Views Asked by At

Why is it that on the playbook.yml under the command task to be executed, some modules have a quotation mark while some does not?

For example, if you check the syntax below, the module line is with embedded in a quotation mark but script is not.

- name: 'Execute a script on all web server nodes and start httpd service'
  hosts: web_nodes

  tasks:

    - name: 'Update entry into /etc/resolv.conf'
      lineinfile:
        path: /etc/resolv.conf
        line: 'nameserver 10.1.250.10' 

    - name: 'Execute a script'
      script: /tmp/install_script.sh
1

There are 1 best solutions below

0
On

Both modules take as parameter for line or cmd a string.

Why is it that ... some modules have a quotation mark while some does not?

Your question is about the YAML Syntax

which is how Ansible playbooks (our configuration management language) are expressed.

when to quote and YAML Gotchas

While you can put just about anything into an unquoted scalar, there are some exceptions.

Also a style guide can be a reason of different ways of when and how to quote.