-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsitev1.yml
48 lines (41 loc) · 1.24 KB
/
sitev1.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
- hosts: all
become: true
tasks: # here we are updating all the systems before any new operations are to be performed
- name: install updates (CentOS)
dnf:
update_only: yes
update_cache: yes
when: ansible_distribution == "CentOS"
- name: install updates (Ubuntu)
apt:
upgrade: dist
update_cache: yes
when: ansible_distribution == "Ubuntu"
# here we are targeting specific servers mentioned in the invernoty file grouping
- hosts: web_servers
become: true
tasks:
- name: install apache and php for Ubuntu servers
apt:
name:
- apache2
- libapache2-mod-php
state: latest
when: ansible_distribution == "Ubuntu"
# This task will copy the html file to all the web servers
- name: copy html file for site
tags: apache,apache,apache2,httpd
copy:
src: site.html # name of the file
dest: /var/www/html/index.html # location of the directories where file is to be copied
owner: root
group: root
mode: 0644 # permission
- name: install apache and php for CentOS servers
dnf:
name:
- httpd
- php
state: latest
when: ansible_distribution == "CentOS"