Skip to content

Instantly share code, notes, and snippets.

@ShubhamRasal
Created December 17, 2020 20:08
Show Gist options
  • Save ShubhamRasal/e5c3d97bd5614918daa7f43b7247671e to your computer and use it in GitHub Desktop.
Save ShubhamRasal/e5c3d97bd5614918daa7f43b7247671e to your computer and use it in GitHub Desktop.
webserver.yml ansible
- hosts: webserver
vars_files:
- vars.yml
tasks:
- name: "Install HTTPD "
package:
name: "httpd"
state: present
register: httpd_install
- name: "Create document root"
file:
path: "{{ document_root_location }}"
state: directory
register: create_dir
when: httpd_install.failed == false
- name: "Copy source code/artifacts "
copy:
src: "{{ source_code_path }}"
dest: "{{ document_root_location }}"
when: create_dir.failed == false
- name: "Copy conf file"
template:
src: "{{ webserver_conf_file }}"
dest: "/etc/httpd/conf.d/{{ project_name }}.conf"
register: x
when: httpd_install.failed == false and create_dir.failed == false
notify: "Restart Httpd"
- name: "Restart firewalld"
service:
name: "firewalld"
state: started
- name: "Add firewall rule"
firewalld:
port: "{{ port_number }}/tcp"
permanent: yes
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