initial: create ansible role

This commit is contained in:
2022-08-01 10:22:00 +07:00
commit ab7a3ac46d
11 changed files with 165 additions and 0 deletions

58
tasks/main.yml Normal file
View File

@@ -0,0 +1,58 @@
---
- name: lighthouse | install dependencies
become: true
ansible.builtin.yum:
name:
- git
- epel-release
- name: lighthouse | create nginx site dir
become: true
ansible.builtin.file:
mode: "755"
owner: "{{ ansible_effective_user_id }}"
group: "{{ ansible_effective_group_id }}"
path: "/var/www"
state: "directory"
- name: lighthouse | clone repository
ansible.builtin.git:
repo: "{{ lighthouse_vcs }}"
dest: "{{ lighthouse_location }}"
version: "{{ lighthouse_vcs_version }}"
- name: lighthouse | config selinux
become: true
ansible.builtin.command:
cmd: chcon -Rt httpd_sys_content_t /var/www
changed_when: false
- name: lighthouse | install nginx
become: true
ansible.builtin.yum:
name: nginx
state: present
- name: lighthouse | create nginx log dir
become: true
ansible.builtin.file:
mode: "755"
owner: "{{ ansible_effective_user_id }}"
group: "{{ ansible_effective_group_id }}"
path: "/var/log/nginx"
state: "directory"
- name: lighthouse | nginx template config
become: true
ansible.builtin.template:
src: "templates/nginx.conf.j2"
dest: "/etc/nginx/nginx.conf"
mode: "755"
- name: lighthouse | nginx lighthouse config
become: true
ansible.builtin.template:
src: "templates/nginx.lighthouse.conf.j2"
dest: "/etc/nginx/conf.d/lighthouse.conf"
mode: "755"
- name: lighthouse | start nginx service
become: true
ansible.builtin.service:
name: nginx
state: started
- name: lighthouse | check service is accessible
ansible.builtin.uri:
url: http://localhost