Skip to content

Commit af4a2ba

Browse files
authored
refactor(ansible): bring our ansible up to modern ansible-lint standards (#1821)
1 parent bbfc14b commit af4a2ba

File tree

1 file changed

+50
-51
lines changed

1 file changed

+50
-51
lines changed

ansible/tasks/setup-nginx.yml

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,78 @@
11
- name: nginx - system user
2-
user: name=nginx
2+
ansible.builtin.user:
3+
name: 'nginx'
4+
state: 'present'
35

46
# Kong installation steps from http://archive.vn/3HRQx
57
- name: nginx - system dependencies
6-
apt:
8+
ansible.builtin.apt:
79
pkg:
8-
- openssl
910
- libpcre3-dev
1011
- libssl-dev
12+
- openssl
1113
- zlib1g-dev
1214

1315
- name: nginx - download source
14-
get_url:
15-
url: "https://nginx.org/download/nginx-{{ nginx_release }}.tar.gz"
16-
dest: /tmp/nginx-{{ nginx_release }}.tar.gz
16+
ansible.builtin.get_url:
1717
checksum: "{{ nginx_release_checksum }}"
18+
dest: '/tmp/nginx-{{ nginx_release }}.tar.gz'
19+
url: "https://nginx.org/download/nginx-{{ nginx_release }}.tar.gz"
1820

1921
- name: nginx - unpack archive
20-
unarchive:
21-
remote_src: yes
22-
src: /tmp/nginx-{{ nginx_release }}.tar.gz
23-
dest: /tmp
22+
ansible.builtin.unarchive:
23+
dest: '/tmp'
24+
remote_src: true
25+
src: "/tmp/nginx-{{ nginx_release }}.tar.gz"
2426

2527
- name: nginx - configure
26-
shell:
27-
chdir: /tmp/nginx-{{ nginx_release }}
28-
cmd: |
29-
set -e
28+
ansible.builtin.command:
29+
argv:
30+
- ./configure
31+
- --prefix=/usr/local/nginx
32+
- --conf-path=/etc/nginx/nginx.conf
33+
- --with-http_ssl_module
34+
- --with-http_realip_module
35+
- --with-threads
36+
args:
37+
chdir: "/tmp/nginx-{{ nginx_release }}"
38+
become: true
3039

31-
./configure \
32-
--prefix=/usr/local/nginx \
33-
--conf-path=/etc/nginx/nginx.conf \
34-
--with-http_ssl_module \
35-
--with-http_realip_module \
36-
--with-threads
37-
become: yes
38-
39-
- name: nginx - build
40+
- name: nginx - build and install
4041
community.general.make:
41-
target: build
42-
chdir: /tmp/nginx-{{ nginx_release }}
42+
chdir: "/tmp/nginx-{{ nginx_release }}"
4343
jobs: "{{ parallel_jobs | default(omit) }}"
44-
become: yes
45-
46-
- name: nginx - install
47-
make:
48-
chdir: /tmp/nginx-{{ nginx_release }}
49-
target: install
50-
become: yes
51-
52-
- name: nginx - hand over ownership of /usr/local/nginx to user nginx
53-
file:
54-
path: /usr/local/nginx
55-
recurse: yes
56-
owner: nginx
44+
target: "{{ make_target }}"
45+
become: true
46+
loop:
47+
- 'build'
48+
- 'install'
49+
loop_control:
50+
loop_var: 'make_target'
5751

58-
- name: nginx - hand over ownership of /etc/nginx to user nginx
59-
file:
60-
path: /etc/nginx
61-
recurse: yes
62-
owner: nginx
52+
- name: nginx - hand over ownership of /etc/nginx and /usr/local/nginx to user nginx
53+
ansible.builtin.file:
54+
owner: 'nginx'
55+
path: "{{ nginx_dir_item }}"
56+
recurse: true
57+
loop:
58+
- /etc/nginx
59+
- /usr/local/nginx
60+
loop_control:
61+
loop_var: 'nginx_dir_item'
6362

6463
# [warn] ulimit is currently set to "1024". For better performance set it to at least
6564
# "4096" using "ulimit -n"
6665
- name: nginx - bump up ulimit
67-
pam_limits:
68-
limit_item: nofile
69-
limit_type: soft
70-
domain: nginx
71-
value: "4096"
66+
community.general.pam_limits:
67+
domain: 'nginx'
68+
limit_item: 'nofile'
69+
limit_type: 'soft'
70+
value: '4096'
7271

7372
- name: nginx - create service file
74-
template:
75-
src: files/nginx.service.j2
76-
dest: /etc/systemd/system/nginx.service
73+
ansible.builtin.template:
74+
dest: '/etc/systemd/system/nginx.service'
75+
src: 'files/nginx.service.j2'
7776

7877
# Keep it dormant for the timebeing
7978

0 commit comments

Comments
 (0)