ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Ansible Syntax

    IT Discussion
    ansible yaml configuration managment linux
    1
    1
    740
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • stacksofplatesS
      stacksofplates
      last edited by stacksofplates

      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
        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,
      }
      
      1 Reply Last reply Reply Quote 3
      • 1 / 1
      • First post
        Last post