2019-02-18 18:40:54 +00:00
|
|
|
---
|
|
|
|
- hosts: all
|
2022-01-01 08:47:25 +00:00
|
|
|
pre_tasks:
|
2022-01-06 22:49:52 +00:00
|
|
|
- name: Include role
|
|
|
|
include_role:
|
|
|
|
name: fake_role
|
2022-01-01 08:47:25 +00:00
|
|
|
- name: Block in pre task
|
|
|
|
block:
|
|
|
|
- name: debug
|
|
|
|
debug:
|
|
|
|
msg: "pre task debug"
|
2019-02-18 18:40:54 +00:00
|
|
|
tasks:
|
2021-09-26 16:18:09 +00:00
|
|
|
- name: Install tree
|
|
|
|
yum:
|
|
|
|
name: tree
|
2019-02-18 18:40:54 +00:00
|
|
|
- name: Install Apache
|
2021-09-26 16:18:09 +00:00
|
|
|
when: (ansible_facts['distribution'] == "CentOS" and ansible_facts['distribution_major_version'] == "6")
|
2019-02-18 18:40:54 +00:00
|
|
|
block:
|
|
|
|
- name: Install some packages
|
|
|
|
yum:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: installed
|
|
|
|
with_items:
|
|
|
|
- httpd
|
|
|
|
- memcached
|
|
|
|
- template:
|
|
|
|
src: templates/src.j2
|
|
|
|
dest: /etc/foo.conf
|
2021-09-26 16:18:09 +00:00
|
|
|
- block:
|
|
|
|
- get_url: url={{ remote_database_dump }} dest={{ local_database_dump }}
|
|
|
|
when: "True"
|
|
|
|
- command: pg_restore -d {{ dbname }} {{ local_database_dump }}
|
2019-02-18 18:40:54 +00:00
|
|
|
- service:
|
|
|
|
name: bar
|
|
|
|
state: started
|
2021-09-26 16:18:09 +00:00
|
|
|
enabled: True
|
2021-10-03 14:04:08 +00:00
|
|
|
- name: Create a username for tomcat
|
|
|
|
user:
|
|
|
|
name: tomcatadm
|
|
|
|
group: users
|
2021-09-26 16:18:09 +00:00
|
|
|
post_tasks:
|
|
|
|
- name: Debug
|
|
|
|
debug:
|
|
|
|
msg: "Debug 1"
|
2022-01-01 08:47:25 +00:00
|
|
|
- name: My post task block
|
|
|
|
block:
|
|
|
|
- template:
|
|
|
|
src: templates/src.j2
|
|
|
|
dest: /etc/foo.conf
|
|
|
|
|