mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-04-11 12:52:10 +07:00
Manage FreeBSD 11
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
---
|
||||
|
||||
- name: APT | Install web apps
|
||||
pkgng:
|
||||
pkg: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- nagios
|
||||
- backuppc
|
||||
|
||||
- name: COMMAND | Activate backuppc config
|
||||
command: >
|
||||
cp /usr/local/etc/backuppc/config.pl.sample /usr/local/etc/backuppc/config.pl
|
||||
creates=/usr/local/etc/backuppc/config.pl
|
||||
|
||||
- name: FILE | Fix backuppc permissions
|
||||
file:
|
||||
path: /usr/local/etc/backuppc/config.pl
|
||||
owner: backuppc
|
||||
group: backuppc
|
||||
|
||||
- name: FILE | Fix fcgiwrap permission
|
||||
file:
|
||||
path: "{{ nginx_fcgiwrap_sock }}"
|
||||
mode: 0640
|
||||
owner: "{{ nginx_user }}"
|
||||
group: "{{ nginx_user }}"
|
||||
#- name: APT | Install web apps
|
||||
# pkgng:
|
||||
# pkg: "{{ item }}"
|
||||
# state: present
|
||||
# with_items:
|
||||
# - nagios
|
||||
# - backuppc
|
||||
#
|
||||
#- name: COMMAND | Activate backuppc config
|
||||
# command: >
|
||||
# cp /usr/local/etc/backuppc/config.pl.sample /usr/local/etc/backuppc/config.pl
|
||||
# creates=/usr/local/etc/backuppc/config.pl
|
||||
#
|
||||
#- name: FILE | Fix backuppc permissions
|
||||
# file:
|
||||
# path: /usr/local/etc/backuppc/config.pl
|
||||
# owner: backuppc
|
||||
# group: backuppc
|
||||
#
|
||||
#- name: FILE | Fix fcgiwrap permission
|
||||
# file:
|
||||
# path: "{{ nginx_fcgiwrap_sock }}"
|
||||
# mode: 0640
|
||||
# owner: "{{ nginx_user }}"
|
||||
# group: "{{ nginx_user }}"
|
||||
|
||||
#
|
||||
# We don't manage BackupPC on FreeBSD... too dirty. :/
|
||||
|
||||
@@ -94,25 +94,6 @@
|
||||
dest: "/tmp"
|
||||
remote_src: yes
|
||||
|
||||
- name: SHELL | Check if ngrok is started
|
||||
shell: ps aux | grep -q [n]grok
|
||||
register: psngrok
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
|
||||
- block:
|
||||
|
||||
- name: SHELL | Start ngrok
|
||||
shell: daemonize /tmp/ngrok http 8888 -bind-tls=false
|
||||
|
||||
- name: WAIT_FOR | ngrok started
|
||||
wait_for:
|
||||
delay: 2
|
||||
port: 4040
|
||||
|
||||
when: psngrok.rc > 0
|
||||
|
||||
- name: SHELL | Get ngrok public address
|
||||
shell: curl 'http://127.0.0.1:4040/api/tunnels/command_line' | jq '.public_url' | grep -oE '[[:alnum:]]+\.ngrok\.io'
|
||||
register: ngrok
|
||||
changed_when: false
|
||||
- name: SET_FACT | ngrok_path
|
||||
set_fact:
|
||||
ngrok_path: '/tmp/ngrok'
|
||||
|
||||
@@ -2,23 +2,35 @@
|
||||
|
||||
- name: SET_FACT | FreeBSD web user
|
||||
set_fact:
|
||||
nginx_pkgng_package: 'nginx-devel'
|
||||
nginx_pkgng_package: 'nginx-full'
|
||||
nginx_user: 'www'
|
||||
nginx_php:
|
||||
- version: '5.6'
|
||||
- version: '7.2'
|
||||
sockets:
|
||||
- host: '127.0.0.1'
|
||||
port: 9000
|
||||
nginx_load_modules:
|
||||
- /usr/local/libexec/nginx/ngx_http_geoip_module.so
|
||||
ngrok_path: '/usr/local/bin/ngrok'
|
||||
|
||||
- name: PKGNG | Install needed packages
|
||||
pkgng:
|
||||
pkg: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- php56
|
||||
- curl
|
||||
- daemonize
|
||||
- fcgiwrap
|
||||
- GeoIP
|
||||
- jq
|
||||
- nghttp2
|
||||
- php72
|
||||
- vim
|
||||
|
||||
- name: COMMAND | Get geoip database
|
||||
command: geoipupdate.sh
|
||||
args:
|
||||
creates: /usr/local/share/GeoIP/GeoIP.dat
|
||||
|
||||
- name: SERVICE | Force start services
|
||||
service:
|
||||
@@ -29,3 +41,25 @@
|
||||
with_items:
|
||||
- php-fpm
|
||||
- fcgiwrap
|
||||
|
||||
- name: STAT | Check ports
|
||||
stat:
|
||||
path: /usr/ports
|
||||
register: ports
|
||||
|
||||
- block:
|
||||
|
||||
- name: COMMAND | Get ports
|
||||
command: portsnap fetch --interactive
|
||||
|
||||
- name: COMMAND | Extract ports
|
||||
command: portsnap extract
|
||||
no_log: true
|
||||
|
||||
when: not ports.stat.exists
|
||||
|
||||
- name: SHELL | Install ngrok
|
||||
shell: make install clean DISABLE_LICENSES=yes
|
||||
args:
|
||||
chdir: /usr/ports/security/ngrok
|
||||
creates: "{{ ngrok_path }}"
|
||||
|
||||
18
tests/includes/pre_common.yml
Normal file
18
tests/includes/pre_common.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
|
||||
- name: SHELL | Start ngrok
|
||||
shell: daemonize -l /tmp/ngrok {{ ngrok_path }} http 8888 -bind-tls=false
|
||||
failed_when: false
|
||||
changed_when: ngrok.stderr.find("Can't lock the lock file") == -1
|
||||
register: ngrok
|
||||
|
||||
- name: WAIT_FOR | ngrok started
|
||||
wait_for:
|
||||
delay: 2
|
||||
port: 4040
|
||||
when: ngrok.changed
|
||||
|
||||
- name: SHELL | Get ngrok public address
|
||||
shell: curl 'http://127.0.0.1:4040/api/tunnels/command_line' | jq '.public_url' | grep -oE '[[:alnum:]]+\.ngrok\.io'
|
||||
register: ngrok
|
||||
changed_when: false
|
||||
@@ -4,22 +4,29 @@
|
||||
pre_tasks:
|
||||
- name: INCLUDE | Pre_tasks related to OS version
|
||||
include: "includes/pre_{{ ansible_distribution }}.yml"
|
||||
|
||||
- name: INCLUDE | Pre_tasks common
|
||||
include: "includes/pre_common.yml"
|
||||
|
||||
- name: FILE | Create an internal SSL dir
|
||||
file:
|
||||
path: "{{ int_ansible_ssl_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: COPY | Deploy test certificate
|
||||
copy:
|
||||
src: "file/test.crt"
|
||||
dest: "{{ int_ansible_ssl_dir }}/test.crt"
|
||||
|
||||
- name: COPY | Deploy test key
|
||||
copy:
|
||||
src: "file/test.key"
|
||||
dest: "{{ int_ansible_ssl_dir }}/test.key"
|
||||
|
||||
- name: LINEINFILE | Add all hosts in /etc/hosts
|
||||
lineinfile:
|
||||
line: "127.0.2.1\t{% for s in nginx_sites %}{% if s.name is string %}{{ s.name }}{% else %}{% for n in s.name %}{{ n }} {% endfor %}{% endif %} {% if s.redirect_from is defined %}{% for rf in s.redirect_from %}{{ rf }} {% endfor %}{% endif %}{% endfor %}"
|
||||
regexp: '^127\.0\.2'
|
||||
line: "127.0.0.1\tlocalhost {% for s in nginx_sites %}{% if s.name is string %}{{ s.name }}{% else %}{% for n in s.name %}{{ n }} {% endfor %}{% endif %} {% if s.redirect_from is defined %}{% for rf in s.redirect_from %}{{ rf }} {% endfor %}{% endif %}{% endfor %}"
|
||||
regexp: '^127\.0\.0\.1'
|
||||
dest: "/etc/hosts"
|
||||
unsafe_writes: yes
|
||||
|
||||
@@ -122,7 +129,7 @@
|
||||
-----END CERTIFICATE-----
|
||||
nginx_custom_http:
|
||||
- 'add_header X-ansible 1;'
|
||||
- 'geoip_country /usr/share/GeoIP/GeoIP.dat;'
|
||||
- 'geoip_country {% if ansible_distribution == "Debian" %}/usr/share/GeoIP/GeoIP.dat{% else %}/usr/local/share/GeoIP/GeoIP.dat{% endif %};'
|
||||
- 'map $geoip_country_code $allowed_country {'
|
||||
- ' default yes;'
|
||||
- ' MA no;'
|
||||
@@ -414,7 +421,7 @@
|
||||
failed_when: authbpc.content.find('BackupPC Server Status') == -1
|
||||
|
||||
# --------------------------------
|
||||
# Nagios (not avaiblable on Debian >= 9)
|
||||
# Nagios (not avaiblable on Debian >= 9 and not tested on FreeBSD)
|
||||
# --------------------------------
|
||||
- block:
|
||||
|
||||
@@ -438,7 +445,7 @@
|
||||
register: nagios_cgi
|
||||
failed_when: nagios_cgi.content.find('Nagios Event Summary') == -1
|
||||
|
||||
when: ansible_distribution_major_version | version_compare('9', 'lt')
|
||||
when: ansible_distribution == 'Debian' and ansible_distribution_major_version | version_compare('9', 'lt')
|
||||
|
||||
|
||||
# --------------------------------
|
||||
|
||||
Reference in New Issue
Block a user