Skip to content

Commit 158b961

Browse files
hunleydencima
authored andcommitted
refactor(ansible): bring our ansible up to modern ansible-lint standards (#1821)
1 parent 122ef4c commit 158b961

File tree

1 file changed

+50
-52
lines changed

1 file changed

+50
-52
lines changed

ansible/tasks/setup-nginx.yml

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +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-
- build-essential
9-
- openssl
1010
- libpcre3-dev
1111
- libssl-dev
12+
- openssl
1213
- zlib1g-dev
1314

1415
- name: nginx - download source
15-
get_url:
16-
url: "https://nginx.org/download/nginx-{{ nginx_release }}.tar.gz"
17-
dest: /tmp/nginx-{{ nginx_release }}.tar.gz
16+
ansible.builtin.get_url:
1817
checksum: "{{ nginx_release_checksum }}"
18+
dest: '/tmp/nginx-{{ nginx_release }}.tar.gz'
19+
url: "https://nginx.org/download/nginx-{{ nginx_release }}.tar.gz"
1920

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

2627
- name: nginx - configure
27-
shell:
28-
chdir: /tmp/nginx-{{ nginx_release }}
29-
cmd: |
30-
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
3139

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

59-
- name: nginx - hand over ownership of /etc/nginx to user nginx
60-
file:
61-
path: /etc/nginx
62-
recurse: yes
63-
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'
6462

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

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

7977
# Keep it dormant for the timebeing
8078

0 commit comments

Comments
 (0)