Fix deprecations (#35)

* Drop Nagios support
* Fix start PHP-FPM on Docker
* Fix deprecations on Ansible 2.7

- with_ -> loop
- fix filters as test
- test version_compare -> version
- set min_version to 2.5
This commit is contained in:
Emilien M
2019-01-24 11:05:46 +01:00
committed by GitHub
parent 87c1c68949
commit 8218e5c972
25 changed files with 71 additions and 191 deletions

View File

@@ -2,17 +2,12 @@
- name: APT | Install webapps
apt:
pkg: "{{ item }}"
pkg: "{{ packages }}"
state: present
install_recommends: no
with_items:
- backuppc
- name: APT | Install nagios3 (only on old Debian releases)
apt:
pkg: nagios3
state: present
when: ansible_distribution_major_version | version_compare('9', 'lt')
vars:
packages:
- backuppc
- name: SERVICE | Ensure backuppc is started
service:

View File

@@ -5,7 +5,6 @@
# pkg: "{{ item }}"
# state: present
# with_items:
# - nagios
# - backuppc
#
#- name: COMMAND | Activate backuppc config
@@ -19,13 +18,6 @@
# 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. :/
#

View File

@@ -45,19 +45,20 @@
- name: APT | Install needed packages
apt:
pkg: "{{ item }}"
pkg: "{{ packages }}"
update_cache: yes
cache_valid_time: 3600
state: present
with_items:
- cron
- curl
- fcgiwrap
- jq
- nghttp2
- strace
- vim
- unzip
vars:
packages:
- cron
- curl
- fcgiwrap
- jq
- nghttp2
- strace
- vim
- unzip
- name: APT | Install daemonize from Stretch
apt:
@@ -69,7 +70,7 @@
update_cache: yes
cache_valid_time: 3600
state: present
with_items: "{{ nginx_php }}"
loop: "{{ nginx_php }}"
register: apt_php
- name: SERVICE | Force start fcgiwrap
@@ -77,11 +78,13 @@
name: "fcgiwrap"
state: started
# Bypasses Ansible 2.4 issue (cannot use service module)... With service module... php is not really started!
# Bypasses Ansible+Docker issue. With service module... php is not really started!
- name: COMMAND | Force start PHP
command: "service {{ item.version | php_fpm_service }} start"
with_items: "{{ nginx_php }}"
when: apt_php.changed
args:
creates: "{{ item.version | php_default_upstream_socket }}"
warn: false
loop: "{{ nginx_php }}"
- name: GET_URL | Download ngrok
get_url:

View File

@@ -15,17 +15,18 @@
- name: PKGNG | Install needed packages
pkgng:
pkg: "{{ item }}"
pkg: "{{ packages }}"
state: present
with_items:
- curl
- daemonize
- fcgiwrap
- GeoIP
- jq
- nghttp2
- php72
- vim
vars:
packages:
- curl
- daemonize
- fcgiwrap
- GeoIP
- jq
- nghttp2
- php72
- vim
- name: COMMAND | Get geoip database
command: geoipupdate.sh
@@ -38,7 +39,7 @@
state: started
enabled: yes
register: sf
with_items:
loop:
- php-fpm
- fcgiwrap

View File

@@ -14,6 +14,8 @@
- 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'
args:
warn: false
register: ngrok
changed_when: false
@@ -22,6 +24,6 @@
line: "set mouse="
dest: "{{ item }}/.vimrc"
create: yes
with_items:
loop:
- /root
- /home/vagrant

View File

@@ -60,11 +60,6 @@
state: 'absent'
- name: 'hanx'
password: 'qwerty'
- name: 'nagios'
description: 'Please login to Nagios!'
users:
- name: 'nagiosadmin'
password: 'nagios'
- name: 'deleteme'
description: 'Please login!'
users: []
@@ -221,9 +216,6 @@
- name: 'backuppc.local'
template: '_backuppc'
htpasswd: 'hello'
- name: 'nagios3.local'
template: '_nagios3'
htpasswd: 'nagios'
- name: 'test-ssl.local'
proto: ['http', 'https']
template: '_base'
@@ -284,7 +276,7 @@
copy:
dest: "{{ nginx_root }}/{{ item }}/public/index.php"
content: "<?php phpinfo();"
with_items:
loop:
- 'test-php.local'
- 'test-php-index.local'
- 'test-php-index2.local'
@@ -293,7 +285,7 @@
copy:
dest: "{{ item }}/index.html"
content: "Index HTML test OK\n"
with_items:
loop:
- '{{ nginx_root }}/first-test/public'
- '/var/tmp'
- '{{ nginx_root }}/test-htpasswd-all.local/public'
@@ -327,7 +319,7 @@
url: "http://{{ item | nginx_site_name }}{% if item.listen is defined %}:{{ item.listen[0] }}{% endif %}/"
status_code: '200,301,302,401,403'
follow_redirects: none
with_items: "{{ nginx_sites }}"
loop: "{{ nginx_sites }}"
when: item.state is undefined or item.state != "absent"
changed_when: false
@@ -341,7 +333,7 @@
url: "http://{{ item.redirect_from[0] }}/"
status_code: 301
follow_redirects: none
with_items: "{{ nginx_sites }}"
loop: "{{ nginx_sites }}"
when: item.redirect_from is defined and (item.state is undefined or item.state != "absent") and (item.proto is not defined or 'https' not in item.proto)
changed_when: false
@@ -351,7 +343,7 @@
status_code: 301
follow_redirects: none
validate_certs: no
with_items: "{{ nginx_sites }}"
loop: "{{ nginx_sites }}"
when: item.redirect_from is defined and (item.state is undefined or item.state != "absent") and item.proto is defined and 'https' in item.proto
changed_when: false
@@ -363,7 +355,7 @@
url: "http://{{ item.name}}/"
return_content: yes
register: p
with_items: "{{ nginx_sites }}"
loop: "{{ nginx_sites }}"
when: >
item.template is defined and
(item.template == '_php' or item.template == '_php_index' or item.template == '_php_index2')
@@ -428,33 +420,6 @@
when: ansible_distribution != 'FreeBSD'
failed_when: authbpc.content.find('BackupPC Server Status') == -1
# --------------------------------
# Nagios (not avaiblable on Debian >= 9 and not tested on FreeBSD)
# --------------------------------
- block:
- name: -- VERIFY NAGIOS3 PHP --
uri:
url: "http://nagios3.local/side.php"
user: "nagiosadmin"
password: "nagios"
force_basic_auth: yes
return_content: yes
register: nagios_php
failed_when: nagios_php.content.find('Nagios Core') == -1
- name: -- VERIFY NAGIOS3 CGI --
uri:
url: "http://nagios3.local/cgi-bin{% if ansible_distribution == 'Debian' %}/nagios3{% endif %}/summary.cgi"
user: "nagiosadmin"
password: "nagios"
force_basic_auth: yes
return_content: yes
register: nagios_cgi
failed_when: nagios_cgi.content.find('Nagios Event Summary') == -1
when: ansible_distribution == 'Debian' and ansible_distribution_major_version | version_compare('9', 'lt')
# --------------------------------
# SSL
# --------------------------------
@@ -465,7 +430,7 @@
validate_certs: no
register: sslok
failed_when: sslok.content.find('Index HTML test OK') == -1
with_items:
loop:
- 'test-ssl-predeployed.local'
- 'test-ssl-selfsigned.local'
- 'test-ssl.local'
@@ -480,7 +445,7 @@
follow_redirects: none
register: sslredirok
failed_when: '"https://%s%s" % (item.name, ":" + item.port if item.port is defined else "") not in sslredirok.location'
with_items:
loop:
- name: 'test-ssl-redirect.local'
- name: 'test-ssl-redirect-many.local'
port: '8443'