❗ Idempotence in Ansible

- name : "Copying wepages to server"
tags : rootdoc
copy :
src : index.html
dest : /var/www/html/
register : rootdoc
- name : Service status
service :
name : httpd
state : restarted
when : rootdoc.changed == true
- hosts: 192.168.0.126
tasks:
- name : Mounting dvd
mount :
src : "/dev/cdrom"
path : "/dvd"
state : mounted
fstype : "iso9660"
- name : "Setting up yum repo"
yum_repository :
name : yum1
description : "Yum repo 1"
baseurl : "/dvd/AppStream"
gpgcheck : 0
- name : "Setting yum repo "
yum_repository :
name : yum2
description : "Yum repo 2"
baseurl : "/dvd/BaseOS"
gpgcheck: 0
- name : "Installing net-tools for cli "
yum :
name : net-tools
state : present

- name : "Installing httpd package"
yum :
name : httpd
state : present
- name : "Copying wepages to server"
tags : rootdoc
copy :
src : index.html
dest : /var/www/html/
register : rootdoc

- debug :
msg : "{{ rootdoc }}"
- name : "Starting httpd server"
service :
name : httpd
state : started
enabled : yes
ignore_errors: yes
- name : Service status
service :
name : httpd
state : restarted
when : rootdoc.changed == true

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ansh@24

Ansh@24

Technological Enthusiast , Like to express what is need of time, Relates real world to philosophical insights