Skip to content

Commit 2289b6a

Browse files
magicalyakalessfg
andauthored
Buildfromsource (#233)
* Add build from source option * Update to Molecule 3.0 * Add service manager to Debian images * Add .gitignore entry for Ansible retry files Co-authored-by: Alessandro Fael Garcia <[email protected]>
1 parent d0548a7 commit 2289b6a

File tree

42 files changed

+1432
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1432
-147
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@
55
__pycache__
66
*~
77
\#*
8+
9+
# OS Specific
10+
Thumbs.db
11+
.DS_Store
12+
.vscode
13+
14+
# Ansible specific
15+
*.retry

.travis.yml

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,56 @@
11
---
2-
sudo: required
32
language: python
43
services:
54
- docker
6-
env:
7-
- scenario: default
8-
- scenario: default_alpine
9-
- scenario: default_centos
10-
- scenario: module
11-
- scenario: module_alpine
12-
- scenario: module_centos
13-
- scenario: stable_push
14-
- scenario: stable_push_alpine
15-
- scenario: stable_push_centos
16-
- scenario: template
17-
- scenario: template_alpine
18-
- scenario: template_centos
19-
- scenario: unit
20-
- scenario: unit_alpine
21-
- scenario: unit_centos
5+
jobs:
6+
include:
7+
- name: "Install Specific Version Test - Debian"
8+
env: scenario=default
9+
- name: "Install Specific Version Test - Alpine"
10+
env: scenario=default_alpine
11+
- name: "Install Specific Version Test - CentOS"
12+
env: scenario=default_centos
13+
- name: "Install Modules Test - Debian"
14+
env: scenario=module
15+
- name: "Install Modules Test - Alpine"
16+
env: scenario=module_alpine
17+
- name: "Install Modules Test - CentOS"
18+
env: scenario=module_centos
19+
- name: "Install Stable Branch and Push Configuration Test - Debian"
20+
env: scenario=stable_push
21+
- name: "Install Stable Branch and Push Configuration Test - Alpine"
22+
env: scenario=stable_push_alpine
23+
- name: "Install Stable Branch and Push Configuration Test - CentOS"
24+
env: scenario=stable_push_centos
25+
- name: "Use Template Setting Test - Debian"
26+
env: scenario=template
27+
- name: "Use Template Setting Test - Alpine"
28+
env: scenario=template_alpine
29+
- name: "Use Template Setting Test - CentOS"
30+
env: scenario=template_centos
31+
- name: "Install Unit Test - Debian"
32+
env: scenario=unit
33+
- name: "Install Unit Test - Alpine"
34+
env: scenario=unit_alpine
35+
- name: "Install Unit Test - CentOS"
36+
env: scenario=unit_centos
37+
- name: "Install from Source Test - Debian"
38+
env: scenario=source
39+
- name: "Install from Source Test - Alpine"
40+
env: scenario=source_alpine
41+
- name: "Install from Source Test - CentOS"
42+
env: scenario=source_centos
2243
before_install:
2344
- sudo apt-get -qq update
2445
install:
25-
- pip install ansible==2.9.4
26-
- pip install molecule[docker]==2.22
46+
- pip install ansible==2.9.6
47+
- pip install molecule[docker]>=3.0.0
48+
- pip install testinfra
49+
- pip install ansible-lint
50+
- pip install flake8
2751
script:
52+
- molecule --version
53+
- ansible --version
2854
- travis_wait 50 molecule test -s $scenario
2955
notifications:
3056
webhooks: https://galaxy.ansible.com/api/v1/notifications/

.yamllint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
extends: default
23

34
rules:

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Instructions on how to install Ansible can be found in the [Ansible website](htt
1919

2020
**Molecule**
2121

22-
Molecule is used to test the various functionailities of the role. Instructions on how to install Molecule can be found in the [Molecule website](https://molecule.readthedocs.io/en/stable/installation.html).
22+
Molecule is used to test the various functionailities of the role. Instructions on how to install Molecule can be found in the [Molecule website](https://molecule.readthedocs.io/en/latest/installation.html).
2323

2424
Installation
2525
------------
@@ -45,6 +45,7 @@ Alpine:
4545
- 3.8
4646
- 3.9
4747
- 3.10
48+
- 3.11
4849
CentOS:
4950
versions:
5051
- 6
@@ -81,6 +82,7 @@ Alpine:
8182
- 3.8
8283
- 3.9
8384
- 3.10
85+
- 3.11
8486
Amazon Linux:
8587
versions:
8688
- 2018.03

defaults/main/linux.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ nginx_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
66
# https://docs.nginx.com/nginx/technical-specs/
77
# RedHat={Amazon,CentOS,OracleLinux,RHEL} Debian={Ubuntu,Debian}
88
nginx_plus_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
9+
10+
# Default locations and versions for install from source
11+
pcre_version: pcre-8.43
12+
zlib_version: zlib-1.2.11
13+
openssl_version: openssl-1.1.1c

defaults/main/main.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,25 @@ nginx_type: opensource
2828
nginx_state: present
2929

3030
# Specify repository origin for NGINX Open Source.
31-
# Options are 'nginx_repository' or 'os_repository'.
31+
# Options are 'nginx_repository', 'source' or 'os_repository'.
3232
# Only works if 'nginx_type' is set to 'opensource'.
3333
# Default is nginx_repository.
3434
nginx_install_from: nginx_repository
3535

36+
# Specify source install options for NGINX Open Source.
37+
# Options represent whether to install from source also
38+
# or to install from packages (default). These only apply
39+
# if 'nginx_install_from' is set to 'source'
40+
# For the tools, true means we will isntall from a package
41+
# and false means install from source.
42+
# 'nginx_install_source_build_tools' will install compiler
43+
# and build tools from packages. If false, you need to have
44+
# these present.
45+
nginx_install_source_build_tools: true
46+
nginx_install_source_pcre: false
47+
nginx_install_source_openssl: true
48+
nginx_install_source_zlib: false
49+
3650
# Choose where to fetch the NGINX signing key from.
3751
# Default is the official NGINX signing key host.
3852
# nginx_signing_key: http://nginx.org/keys/nginx_signing.key
@@ -44,7 +58,7 @@ nginx_install_from: nginx_repository
4458

4559
# Specify which branch of NGINX Open Source you want to install.
4660
# Options are 'mainline' or 'stable'.
47-
# Only works if 'install_from' is set to 'nginx_repository'.
61+
# Only works if 'install_from' is set to 'nginx_repository' or 'source'.
4862
# Default is mainline.
4963
nginx_branch: mainline
5064

files/services/nginx.conf.upstart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
description "nginx - small, powerful, scalable web/proxy server"
2+
3+
start on filesystem and static-network-up
4+
stop on runlevel [016]
5+
6+
expect fork
7+
respawn
8+
9+
pre-start script
10+
[ -x /usr/sbin/nginx ] || { stop; exit 0; }
11+
/usr/sbin/nginx -q -t -g 'daemon on; master_process on;' || { stop; exit 0; }
12+
end script
13+
14+
exec /usr/sbin/nginx -g 'daemon on; master_process on;'
15+
16+
pre-stop exec /usr/sbin/nginx -s quit

files/services/nginx.openrc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/sbin/openrc-run
2+
3+
description="Nginx http and reverse proxy server"
4+
extra_commands="checkconfig"
5+
extra_started_commands="reload reopen upgrade"
6+
7+
cfgfile=${cfgfile:-/etc/nginx/nginx.conf}
8+
pidfile=/var/run/nginx.pid
9+
command=/usr/sbin/nginx
10+
command_args="-c $cfgfile"
11+
required_files="$cfgfile"
12+
13+
depend() {
14+
need net
15+
use dns logger netmount
16+
}
17+
18+
start_pre() {
19+
$command $command_args -t -q
20+
}
21+
22+
checkconfig() {
23+
ebegin "Checking $RC_SVCNAME configuration"
24+
start_pre
25+
eend $?
26+
}
27+
28+
reload() {
29+
ebegin "Reloading $RC_SVCNAME configuration"
30+
start_pre && start-stop-daemon --signal HUP --pidfile $pidfile
31+
eend $?
32+
}
33+
34+
reopen() {
35+
ebegin "Reopening $RC_SVCNAME log files"
36+
start-stop-daemon --signal USR1 --pidfile $pidfile
37+
eend $?
38+
}
39+
40+
upgrade() {
41+
start_pre || return 1
42+
43+
ebegin "Upgrading $RC_SVCNAME binary"
44+
45+
einfo "Sending USR2 to old binary"
46+
start-stop-daemon --signal USR2 --pidfile $pidfile
47+
48+
einfo "Sleeping 3 seconds before pid-files checking"
49+
sleep 3
50+
51+
if [ ! -f $pidfile.oldbin ]; then
52+
eerror "File with old pid ($pidfile.oldbin) not found"
53+
return 1
54+
fi
55+
56+
if [ ! -f $pidfile ]; then
57+
eerror "New binary failed to start"
58+
return 1
59+
fi
60+
61+
einfo "Sleeping 3 seconds before WINCH"
62+
sleep 3 ; start-stop-daemon --signal 28 --pidfile $pidfile.oldbin
63+
64+
einfo "Sending QUIT to old binary"
65+
start-stop-daemon --signal QUIT --pidfile $pidfile.oldbin
66+
67+
einfo "Upgrade completed"
68+
69+
eend $? "Upgrade failed"
70+
}

files/services/nginx.systemd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Unit]
2+
Description=nginx - high performance web server
3+
Documentation=http://nginx.org/en/docs/
4+
After=network-online.target remote-fs.target nss-lookup.target
5+
Wants=network-online.target
6+
7+
[Service]
8+
Type=forking
9+
PIDFile=/var/run/nginx.pid
10+
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
11+
ExecReload=/bin/kill -s HUP $MAINPID
12+
ExecStop=/bin/kill -s TERM $MAINPID
13+
14+
[Install]
15+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)