Here is my code:
- name: Install httpd and setup index.html
hosts: stapp01, stapp02, stapp03
become: yes
tasks:- name: Install httpd
package:
name: httpd
state: present - name: Start service httpd, if not started
service:
name: httpd
state: started - name: Add content block in index.html. Create file if does not exist and and set file attributes
copy:
dest: /var/www/html/index.html
content: This is Nautilus sample file, created using Ansible!
mode: “0755”
owner: apache
group: apache - name: Update content in index.html
lineinfile:
path: /var/www/html/index.html
insertbefore: BOF
line: Welcome to Nautilus Group!
- name: Install httpd