Separate installation of Linux and BSD (#182)

* Added variable nginx_linux_families: ['Debian', 'RedHat', 'Suse']
* Added variable nginx_bsd_systems: ['FreeBSD', 'NetBSD', 'OpenBSD', 'DragonFlyBSD', 'HardenedBSD']
* Handler started only in "not ansible_check_mode" to avoid --check failure when service hes not been installed yet
* Installation of Linux moved to install-oss-linux.yml
* Installation of BSD moved to install-oss-bsd.yml
* File setup-freebsd.yml deleted
This commit is contained in:
Vladimir Botka 2019-11-18 21:09:10 +01:00 committed by Alessandro Fael Garcia
parent 78c21d4346
commit 27d94628bd
6 changed files with 153 additions and 47 deletions

View File

@ -10,6 +10,10 @@ nginx_start: true
# Print NGINX configuration file to terminal after executing playbook. # Print NGINX configuration file to terminal after executing playbook.
nginx_debug_output: false nginx_debug_output: false
# Supported systems
nginx_linux_families: ['Debian', 'RedHat', 'Suse']
nginx_bsd_systems: ['FreeBSD', 'NetBSD', 'OpenBSD', 'DragonFlyBSD', 'HardenedBSD']
# Specify which type of NGINX you want to install. # Specify which type of NGINX you want to install.
# Options are 'opensource' or 'plus'. # Options are 'opensource' or 'plus'.
# Default is 'opensource'. # Default is 'opensource'.
@ -50,6 +54,22 @@ nginx_repository:
https://nginx.org/packages/{{ (nginx_branch == 'mainline') https://nginx.org/packages/{{ (nginx_branch == 'mainline')
| ternary('mainline/', '') }}sles/{{ ansible_distribution_major_version }} | ternary('mainline/', '') }}sles/{{ ansible_distribution_major_version }}
# Choose to install BSD packages or ports.
# Options are True for packages or False for ports.
# Default is True.
nginx_bsd_install_packages: true
# Choose to update BSD ports collection.
# Options are True for update or False for do not update.
# Default is True.
nginx_bsd_update_ports: true
# Choose to install packages built from BSD ports collection if
# available.
# Options are True for use packages or False for do not use packages.
# Default is True.
nginx_bsd_portinstall_use_packages: true
# Specify which branch of NGINX Open Source you want to install. # Specify which branch of NGINX Open Source you want to install.
# Options are 'mainline' or 'stable'. # Options are 'mainline' or 'stable'.
# Only works if 'install_from' is set to 'nginx_repository'. # Only works if 'install_from' is set to 'nginx_repository'.

View File

@ -13,7 +13,9 @@
name: nginx name: nginx
state: reloaded state: reloaded
when: nginx_start | bool when:
- nginx_start | bool
- not ansible_check_mode
- name: "(Handler: All OSs) Start NGINX Amplify Agent" - name: "(Handler: All OSs) Start NGINX Amplify Agent"
service: service:

View File

@ -0,0 +1,103 @@
---
- name: "(Install: FreeBSD) Update ports"
block:
- name: "(Install: FreeBSD) Fetch Ports"
command: portsnap fetch --interactive
args:
creates: /var/db/portsnap/INDEX
- name: "(Install: FreeBSD) Extract Ports"
command: portsnap extract
args:
creates: /usr/ports
when:
- ansible_system == 'FreeBSD'
- nginx_bsd_update_ports
- name: "(Install: FreeBSD)"
block:
- name: "(Install: FreeBSD) Install NGINX package"
pkgng:
name: "www/nginx{{ nginx_version | default('') }}"
state: present
when: nginx_bsd_install_packages
notify: "(Handler: All OSs) Start NGINX"
- name: "(Install: FreeBSD) Install NGINX port"
portinstall:
name: "www/nginx{{ nginx_version | default('') }}"
use_packages: "{{ nginx_bsd_portinstall_use_packages | default(omit) }}"
state: present
when: not nginx_bsd_install_packages
notify: "(Handler: All OSs) Start NGINX"
when: ansible_system == 'FreeBSD'
- name: "(Install: OpenBSD)"
block:
- name: "(Install: OpenBSD) Install NGINX package"
openbsd_pkg:
name: "nginx{{ nginx_version | default('') }}"
build: false
state: present
when: nginx_bsd_install_packages
notify: "(Handler: All OSs) Start NGINX"
- name: "(Install: OpenBSD) Install NGINX port"
openbsd_pkg:
name: "nginx{{ nginx_version | default('') }}"
build: true
state: present
when: not nginx_bsd_install_packages
notify: "(Handler: All OSs) Start NGINX"
when: ansible_system == 'OpenBSD'
- name: "(Install: NetBSD)"
block:
- name: "(Install: NetBSD) Install NGINX package"
command: "pkg_add www/nginx{{ nginx_version | default('') }}"
when: nginx_bsd_install_packages
notify: "(Handler: All OSs) Start NGINX"
- name: "(Install: NetBSD) Install NGINX port"
fail:
msg: "{{ ansible_system }} Install NGINX port not implemented."
when: not nginx_bsd_install_packages
when: ansible_system == 'NetBSD'
- name: "(Install: DragonFlyBSD)"
block:
- name: "(Install: DragonFlyBSD) Install NGINX package"
command: "pkg install www/nginx{{ nginx_version | default('') }}"
when: nginx_bsd_install_packages
notify: "(Handler: All OSs) Start NGINX"
- name: "(Install: DragonFlyBSD) Install NGINX port"
fail:
msg: "{{ ansible_system }} Install NGINX port not implemented."
when: not nginx_bsd_install_packages
when: ansible_system == 'DragonFlyBSD'
- name: "(Install: HardenedBSD)"
block:
- name: "(Install: HardenedBSD) Install NGINX package"
command: "pkg install www/nginx{{ nginx_version | default('') }}"
when: nginx_bsd_install_packages
notify: "(Handler: All OSs) Start NGINX"
- name: "(Install: HardenedBSD) Install NGINX port"
fail:
msg: "{{ ansible_system }} Install NGINX port not implemented."
when: not nginx_bsd_install_packages
when: ansible_system == 'HardenedBSD'

View File

@ -0,0 +1,21 @@
---
- name: "(Install: Linux) Configure NGINX repo"
block:
- import_tasks: setup-debian.yml
when: ansible_os_family == "Debian"
- import_tasks: setup-redhat.yml
when: ansible_os_family == "RedHat"
- import_tasks: setup-suse.yml
when: ansible_os_family == "Suse"
when: nginx_install_from == "nginx_repository"
- name: "(Install: Linux) Install NGINX package"
package:
name: "nginx{{ nginx_version | default('') }}"
state: present
when: ansible_os_family in nginx_linux_families
notify: "(Handler: All OSs) Start NGINX"

View File

@ -1,38 +1,8 @@
--- ---
- name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX" - name: "(Install: OSS Linux)"
block: import_tasks: install-oss-linux.yml
when: ansible_os_family in nginx_linux_families
- import_tasks: setup-debian.yml - name: "(Install: OSS BSD)"
when: ansible_os_family == "Debian" import_tasks: install-oss-bsd.yml
when: ansible_system in nginx_bsd_systems
- import_tasks: setup-redhat.yml
when: ansible_os_family == "RedHat"
- import_tasks: setup-suse.yml
when: ansible_os_family == "Suse"
- import_tasks: setup-freebsd.yml
when: ansible_os_family == "FreeBSD"
- name: "(Install: Debian/Ubuntu/CentOS/RedHat) Install NGINX"
package:
name: "nginx{{ nginx_version | default('') }}"
state: present
when: ansible_os_family != "FreeBSD"
notify: "(Handler: All OSs) Start NGINX"
- name: "(Install: FreeBSD) Install NGINX"
portinstall:
name: nginx
state: present
when: ansible_os_family == "FreeBSD"
notify: "(Handler: All OSs) Start NGINX"
when: nginx_install_from == "nginx_repository"
- name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX"
package:
name: "nginx{{ nginx_version | default('') }}"
state: present
when: nginx_install_from == "os_repository"
notify: "(Handler: All OSs) Start NGINX"

View File

@ -1,10 +0,0 @@
---
- name: "(Install: FreeBSD) Fetch Ports"
command: portsnap fetch --interactive
args:
creates: /var/db/portsnap/INDEX
- name: "(Install: FreeBSD) Extract Ports"
command: portsnap extract
args:
creates: /usr/ports