O'Reilly logo

Ansible Configuration Management - Second Edition by Daniel Hall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The task section

The task section is the last section of each play. It contains a list of actions that we want Ansible to perform in the order we want them to be performed. There are several styles in which we can express each module's arguments. We suggest you try to stick with one as much as possible, and use the others only when required. This makes our playbooks easier to read and maintain. The following code snippet is what a task section looks like with all three styles shown:

tasks:
  - name: install apache
    action: yum name=httpd state=installed

  - name: configure apache
    copy: src=files/httpd.conf dest=/etc/httpd/conf/httpd.conf

  - name: restart apache
    service:
      name: httpd
      state: restarted

Here we see the three different styles of syntax being ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required