mirror of
https://github.com/Dannecron/netology-devops-ansible-lighthouse.git
synced 2025-12-25 13:32:34 +03:00
initial: create ansible role
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/.idea
|
||||||
39
README.md
Normal file
39
README.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
ansible-lighthouse
|
||||||
|
=========
|
||||||
|
|
||||||
|
Данный playbook устанавливает `lighthouse` (доступ через webserver `nginx`).
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
- `nginx_username` - имя пользователя, из-под которого будет запущен процесс `nginx`
|
||||||
|
- `lighthouse_vcs` - путь до репозитория `lighthouse`
|
||||||
|
- `lighthouse_vcs_version` - версия внутри репозитория `lighthouse` (хэш коммита)
|
||||||
|
- `lighthouse_location` - путь до директории с `lighthouse`
|
||||||
|
- `lighthouse_access_log_name` - название лог-файла `nginx` для web-сервиса `lighthouse`
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
- name: lighthouse
|
||||||
|
hosts: lighthouse
|
||||||
|
roles:
|
||||||
|
- lighthouse
|
||||||
|
```
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
BSD
|
||||||
6
defaults/main.yml
Normal file
6
defaults/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
nginx_username: user
|
||||||
|
lighthouse_vcs: https://github.com/VKCOM/lighthouse.git
|
||||||
|
lighthouse_vcs_version: d701335c25cd1bb9b5155711190bad8ab852c2ce
|
||||||
|
lighthouse_location: /var/www/lighthouse
|
||||||
|
lighthouse_access_log_name: lighthouse
|
||||||
2
handlers/main.yml
Normal file
2
handlers/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# handlers file for lighthouse
|
||||||
12
meta/main.yml
Normal file
12
meta/main.yml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: dannc
|
||||||
|
description: install web server and lighthouse
|
||||||
|
company: ""
|
||||||
|
license: BSD-3-Clause
|
||||||
|
min_ansible_version: "2.1"
|
||||||
|
platforms:
|
||||||
|
- name: EL
|
||||||
|
versions:
|
||||||
|
- all
|
||||||
|
galaxy_tags: []
|
||||||
|
dependencies: []
|
||||||
58
tasks/main.yml
Normal file
58
tasks/main.yml
Normal 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
|
||||||
28
templates/nginx.conf.j2
Normal file
28
templates/nginx.conf.j2
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
user {{ nginx_username }};
|
||||||
|
|
||||||
|
worker_processes auto;
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
pid /run/nginx.pid;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
keepalive_timeout 65;
|
||||||
|
types_hash_max_size 4096;
|
||||||
|
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
}
|
||||||
10
templates/nginx.lighthouse.conf.j2
Normal file
10
templates/nginx.lighthouse.conf.j2
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
access_log /var/log/nginx/{{ lighthouse_access_log_name }}.log;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root {{ lighthouse_location }};
|
||||||
|
index index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
tests/inventory
Normal file
2
tests/inventory
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
||||||
5
tests/test.yml
Normal file
5
tests/test.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- lighthouse
|
||||||
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for lighthouse
|
||||||
Reference in New Issue
Block a user