Skip to content

Instantly share code, notes, and snippets.

@rifkiaz
Created November 21, 2019 16:44
Show Gist options
  • Save rifkiaz/b2534fc8a3a35c4e3588c70cec11b332 to your computer and use it in GitHub Desktop.
Save rifkiaz/b2534fc8a3a35c4e3588c70cec11b332 to your computer and use it in GitHub Desktop.
Code for site.yml example site for Ansible
---
- name: install and start httpd
hosts: web
tasks:
- name: install epel repo
yum: name=epel-release state=latest
- name: install python bindings for selinux
yum: name={{item}} state=latest
with_items:
- libselinux-python
- libsemanage-python
- name: test to see if selinux is running
command: getenforce
register: sestatus
changed_when: false
- name: install httpd
yum: name=httpd state=latest
notify: restart httpd
- name: start httpd service
service: name=httpd state=started enabled=yes
- name: copy index.html
template: src=index.html.j2 dest=/var/www/html/index.html
- name: install firewalld
yum: name=firewalld state=latest
- name: start firewalld service
service: name=firewalld state=started enabled=yes
- name: insert firewalld rule
firewalld: service=http permanent=true state=enabled immediate=yes
handlers:
- name: restart httpd
service: name=httpd state=restarted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment