Skip to content

Commit 6e6c5c6

Browse files
Getting started with ansible playbooks
1 parent bedcb57 commit 6e6c5c6

File tree

4 files changed

+43
-0
lines changed

4 files changed

+43
-0
lines changed

ansible/ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
INVENTORY = inventory

ansible/inventory

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[example]
2+
18.192.38.240

ansible/playbook.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- hosts: all
3+
become: yes
4+
tasks:
5+
- name: Ensure HTTP is installed
6+
yum:
7+
name: httpd
8+
state: present
9+
- name: Ensure HTTP is running
10+
service:
11+
name: httpd
12+
state: started
13+
enabled: yes

ansible/web-servers.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
- name: Update web servers
3+
hosts: example
4+
remote_user: ec2-user
5+
become: yes
6+
7+
tasks:
8+
- name: Ensure apache is at the latest version
9+
ansible.builtin.yum:
10+
name: httpd
11+
state: latest
12+
13+
- name: Update db servers
14+
hosts: example
15+
remote_user: ec2-user
16+
become: yes
17+
18+
tasks:
19+
- name: Ensure postgresql is at the latest version
20+
ansible.builtin.yum:
21+
name: postgresql
22+
state: latest
23+
- name: Ensure that postgresql is started
24+
ansible.builtin.service:
25+
name: postgresql
26+
state: started

0 commit comments

Comments
 (0)