Ansible Syntax

  • So I recently learned that you can use a YAML dictionary for your tasks instead of the normal key=value syntax. So for example this task:

    - name: Copy issue template
      template: src=issue.j2 dest=/etc/issue owner=root group=root mode=0644

    is the same as:

    - name: Copy issue template
        src: issue.j2
        dest: /etc/issue
        owner: root
        group: root
        mode: 0644

    At least to me the second way is easier to read, and is more in line with other CM tools like Puppet where that would be:

    file { '/etc/issue':
        content => template('ssh/issue.erb'),
        owner   => root,
        group   => root,
        mode    => 644,