Skip to content

Instantly share code, notes, and snippets.

@Vortexdude
Created November 21, 2022 12:22
Show Gist options
  • Save Vortexdude/a02988b780b431d6f2049fad7b1eb85b to your computer and use it in GitHub Desktop.
Save Vortexdude/a02988b780b431d6f2049fad7b1eb85b to your computer and use it in GitHub Desktop.
- name: Ansible Playbook to Install and Setup Apache on Ubuntu
hosts: myservers
become: yes
tasks:
- name: Install latest version of Apache
apt: name=apache2 update_cache=yes state=latest
- name: Create document root for domain configured in host variable
file:
path: "/var/www/{{ http_host }}"
state: directory
owner: www-data
group: www-data
mode: '0755'
- name: Copy your index file
template:
src: "files/index-template.html"
dest: "/var/www/{{ http_host }}/index.html"
- name: Set up virtuahHost
template:
src: "files/apache-template.conf"
dest: "/etc/apache2/sites-available/{{ http_conf }}"
- name: Enable site
command: a2ensite {{ http_conf }}
notify: restart-apache
- name: "UFW firewall allow HTTP on port {{ http_port }}"
ufw:
rule: allow
port: "{{ http_port }}"
proto: tcp
handlers:
- name: restart-apache
service:
name: apache2
state: restarted
@Vortexdude
Copy link
Author

apache installation by ansible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment