yum installをansibleにまとめたい

ドキュメントに書いても良いが、やはりansibleでまとめたい。

hosts

192.168.33.10

ansible.cnf

[defaults]
hostfile =./hosts

playbook.yml

---
- hosts: all
  sudo: yes
  tasks:
    - name: install apache
      yum: name=httpd state=latest
    - name: start apache and enabled
      service: name=httpd state=started enabled=yes

[vagrant@localhost ansible]$ ansible-playbook playbook.yml –connection=local
[DEPRECATION WARNING]: [defaults]hostfile option, The key is misleading as it
can also be a list of hosts, a directory or a list of paths , use [defaults]
inventory=/path/to/file|dir instead. This feature will be removed in version
2.8. Deprecation warnings can be disabled by setting deprecation_warnings=False
in ansible.cfg.
[DEPRECATION WARNING]: Instead of sudo/sudo_user, use become/become_user and
make sure become_method is ‘sudo’ (default). This feature will be removed in
version 2.6. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [192.168.33.10]

TASK [install apache] **********************************************************
changed: [192.168.33.10]

TASK [start apache and enabled] ************************************************
changed: [192.168.33.10]

PLAY RECAP *********************************************************************
192.168.33.10 : ok=3 changed=2 unreachable=0 failed=0

ansibleのyum moduleのページを見てみましょう。
https://docs.ansible.com/ansible/latest/modules/yum_module.html#yum-module

- name: Install a list of packages
  yum:
    name:
      - nginx
      - postgresql
      - postgresql-server
    state: present

なるほど、これで、middlewareを追加していけば良いのかな。