Created
December 24, 2020 18:50
-
-
Save ShubhamRasal/64f99673f7d0c3bc48ab9c25cf419c7c to your computer and use it in GitHub Desktop.
configure webservre and load balancer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "Webserver" | |
hosts: creatorsbyheart_webservers | |
vars_files: | |
- webservers/vars.yml | |
tags: | |
- "webservers" | |
become: true | |
tasks: | |
- name: "Installation" | |
package: | |
name: "{{ item }}" | |
state: present | |
loop: | |
- "httpd" | |
- "php" | |
register: installation | |
- name: "Create document root" | |
file: | |
path: "{{ document_root_location }}" | |
state: directory | |
register: create_dir | |
when: installation.msg == "All items completed" | |
- 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: installation.msg == "All items completed" and create_dir.failed == false | |
notify: "Restart Httpd" | |
handlers: | |
- name: "Restart Httpd" | |
service: | |
name: "httpd" | |
state: restarted | |
- name: "Load Balancer" | |
hosts: aws_loadbalancer | |
vars_files: | |
- loadbalancer/vars.yml | |
- webservers/vars.yml | |
tags: | |
- "loadbalancer" | |
become: true | |
tasks: | |
- name: "Install Haproxy" | |
package: | |
name: "haproxy" | |
state: present | |
register: haproxy_install | |
- name: "Copy template haproxy config file" | |
template: | |
src: "loadbalancer/haproxy.cfg.j2" | |
dest: "/etc/haproxy/haproxy.cfg" | |
notify: "Restart haproxy" | |
handlers: | |
- name: "Restart haproxy" | |
service: | |
name: "haproxy" | |
state: restarted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment