Skip to content

Commit 36ac951

Browse files
authored
Merge pull request #1 from f500/ansible-lint
Add ansible lint pr workflow
2 parents 439aa45 + 18f7ba0 commit 36ac951

File tree

9 files changed

+223
-61
lines changed

9 files changed

+223
-61
lines changed

.ansible-lint

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
# .ansible-lint
3+
4+
profile: production # min, basic, moderate,safety, shared, production
5+
6+
# Allows dumping of results in SARIF format
7+
# sarif_file: result.sarif
8+
9+
# exclude_paths included in this file are parsed relative to this file's location
10+
# and not relative to the CWD of execution. CLI arguments passed to the --exclude
11+
# option are parsed relative to the CWD of execution.
12+
exclude_paths:
13+
- .github/
14+
- .ansible-lint
15+
# parseable: true
16+
# quiet: true
17+
# strict: true
18+
# verbosity: 1
19+
20+
# Mock modules or roles in order to pass ansible-playbook --syntax-check
21+
#mock_modules:
22+
# - zuul_return
23+
# note the foo.bar is invalid as being neither a module or a collection
24+
# - fake_namespace.fake_collection.fake_module
25+
# - fake_namespace.fake_collection.fake_module.fake_submodule
26+
#mock_roles:
27+
# - mocked_role
28+
# - author.role_name # old standalone galaxy role
29+
# - fake_namespace.fake_collection.fake_role # role within a collection
30+
31+
# Enable checking of loop variable prefixes in roles
32+
loop_var_prefix: "^(__|{role}_)"
33+
34+
# Enforce variable names to follow pattern below, in addition to Ansible own
35+
# requirements, like avoiding python identifiers. To disable add `var-naming`
36+
# to skip_list.
37+
var_naming_pattern: "^[a-z_][a-z0-9_]*$"
38+
39+
use_default_rules: true
40+
# Load custom rules from this specific folder
41+
# rulesdir:
42+
# - ./rule/directory/
43+
44+
# Ansible-lint is able to recognize and load skip rules stored inside
45+
# `.ansible-lint-ignore` (or `.config/ansible-lint-ignore.txt`) files.
46+
# To skip a rule just enter filename and tag, like "playbook.yml package-latest"
47+
# on a new line.
48+
# Optionally you can add comments after the tag, prefixed by "#". We discourage
49+
# the use of skip_list below because that will hide violations from the output.
50+
# When putting ignores inside the ignore file, they are marked as ignored, but
51+
# still visible, making it easier to address later.
52+
skip_list:
53+
- risky-shell-pipe
54+
# - skip_this_tag
55+
56+
# Ansible-lint does not automatically load rules that have the 'opt-in' tag.
57+
# You must enable opt-in rules by listing each rule 'id' below.
58+
enable_list:
59+
- args
60+
- empty-string-compare # opt-in
61+
- no-log-password # opt-in
62+
- no-same-owner # opt-in
63+
- name[prefix] # opt-in
64+
- galaxy-version-incorrect # opt-in
65+
# add yaml here if you want to avoid ignoring yaml checks when yamllint
66+
# library is missing. Normally its absence just skips using that rule.
67+
- yaml
68+
# Report only a subset of tags and fully ignore any others
69+
# tags:
70+
# - jinja[spacing]
71+
72+
# Ansible-lint does not fail on warnings from the rules or tags listed below
73+
#warn_list:
74+
# - skip_this_tag
75+
# - experimental # experimental is included in the implicit list
76+
# - role-name
77+
# - yaml[document-start] # you can also use sub-rule matches
78+
79+
# Some rules can transform files to fix (or make it easier to fix) identified
80+
# errors. `ansible-lint --fix` will reformat YAML files and run these transforms.
81+
# By default it will run all transforms (effectively `write_list: ["all"]`).
82+
# You can disable running transforms by setting `write_list: ["none"]`.
83+
# Or only enable a subset of rule transforms by listing rules/tags here.
84+
# write_list:
85+
# - all
86+
87+
# Offline mode disables installation of requirements.yml and schema refreshing
88+
offline: true
89+
90+
# Define required Ansible's variables to satisfy syntax check
91+
#extra_vars:
92+
# foo: bar
93+
# multiline_string_variable: |
94+
# line1
95+
# line2
96+
# complex_variable: ":{;\t$()"
97+
98+
# Uncomment to enforce action validation with tasks, usually is not
99+
# needed as Ansible syntax check also covers it.
100+
# skip_action_validation: false
101+
102+
# List of additional kind:pattern to be added at the top of the default
103+
# match list, first match determines the file kind.
104+
#kinds:
105+
# - playbook: "**/examples/*.{yml,yaml}"
106+
# - galaxy: "**/folder/galaxy.yml"
107+
# - tasks: "**/tasks/*.yml"
108+
# - vars: "**/vars/*.yml"
109+
# - meta: "**/meta/main.yml"
110+
# - yaml: "**/*.yaml-too"
111+
112+
# List of additional collections to allow in only-builtins rule.
113+
# only_builtins_allow_collections:
114+
# - example_ns.example_collection
115+
116+
# List of additions modules to allow in only-builtins rule.
117+
# only_builtins_allow_modules:
118+
# - example_module
119+
120+
# Allow setting custom prefix for name[prefix] rule
121+
#task_name_prefix: "{stem} | "
122+
# Complexity related settings
123+
124+
# Limit the depth of the nested blocks:
125+
# max_block_depth: 20
126+
127+
# Also recognize these versions of Ansible as supported:
128+
# supported_ansible_also:
129+
# - "2.14"

.github/workflows/pull-request.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Pull request
3+
4+
on: pull_request
5+
6+
jobs:
7+
ansible-lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Run ansible-lint
12+
uses: ansible/ansible-lint@main

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,22 @@ Example Playbook
157157
roles:
158158
- { role: f500.php8, php8_version: 8.0, php8_enable_fpm: yes }
159159

160+
Linting
161+
-------
162+
Github actions will check this role with ansible-lint. To run this locally, you will need to follow the following steps:
163+
164+
```bash
165+
brew install ansible-lint
166+
brew install yamllint
167+
ansible-lint
168+
```
169+
170+
to fix the linting errors, run:
171+
172+
```bash
173+
ansible-lint --fix
174+
```
175+
160176
License
161177
-------
162178

defaults/main.yml

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,48 @@
22

33
php8_version: 8.0
44

5-
php8_enable_apache: no
6-
php8_enable_cgi: no
7-
php8_enable_fpm: no
5+
php8_enable_apache: false
6+
php8_enable_cgi: false
7+
php8_enable_fpm: false
88

9-
php8_enable_dev: no
9+
php8_enable_dev: false
1010

1111
php8_ini_directives_default:
12-
allow_url_fopen: no
12+
allow_url_fopen: false
1313
disable_functions: "exec, passthru, shell_exec, system, proc_open, popen, curl_exec, curl_multi_exec"
14-
expose_php: no
15-
session.cookie_httponly: yes
16-
session.cookie_secure: yes
14+
expose_php: false
15+
session.cookie_httponly: true
16+
session.cookie_secure: true
1717
session.hash_bits_per_character: 4
1818
session.hash_function: sha256
1919
session.sid_bits_per_character: 4
2020
session.sid_length: 64
21-
session.use_strict_mode: yes
21+
session.use_strict_mode: true
2222

2323
php8_ini_directives_global: {}
2424
php8_ini_directives_cli: {}
2525
php8_ini_directives_apache: {}
2626
php8_ini_directives_cgi: {}
2727
php8_ini_directives_fpm: {}
28-
2928
php8_extensions: []
3029
php8_versioned_extensions: []
31-
3230
php8_fpm_pid: "/run/php/php{{ php8_version }}-fpm.pid"
3331
php8_fpm_error_log: "/var/log/php{{ php8_version }}-fpm.log"
3432
php8_fpm_log_level: warning
35-
php8_fpm_syslog_facility: ~
36-
php8_fpm_syslog_ident: ~
33+
php8_fpm_syslog_facility:
34+
php8_fpm_syslog_ident:
3735
php8_fpm_emergency_restart_threshold: 0
3836
php8_fpm_emergency_restart_interval: 0
3937
php8_fpm_process_control_timeout: 0
4038
php8_fpm_process_max: 0
41-
php8_fpm_process_priority: ~
42-
php8_fpm_daemonize: yes
43-
php8_fpm_rlimit_files: ~
44-
php8_fpm_rlimit_core: ~
39+
php8_fpm_process_priority:
40+
php8_fpm_daemonize: true
41+
php8_fpm_rlimit_files:
42+
php8_fpm_rlimit_core:
4543
php8_fpm_events_mechanism: epoll
4644
php8_fpm_systemd_interval: 10
4745

48-
php8_fpm_pool_enabled: yes
46+
php8_fpm_pool_enabled: true
4947
php8_fpm_pool_name: www
5048
php8_fpm_pool_user: www-data
5149
php8_fpm_pool_group: www-data
@@ -54,9 +52,9 @@ php8_fpm_pool_listen_backlog: 512
5452
php8_fpm_pool_listen_owner: "{{ php8_fpm_pool_user }}"
5553
php8_fpm_pool_listen_group: "{{ php8_fpm_pool_group }}"
5654
php8_fpm_pool_listen_mode: "0660"
57-
php8_fpm_pool_listen_acl_users: ~
58-
php8_fpm_pool_listen_acl_groups: ~
59-
php8_fpm_pool_listen_allowed_clients: ~
55+
php8_fpm_pool_listen_acl_users:
56+
php8_fpm_pool_listen_acl_groups:
57+
php8_fpm_pool_listen_allowed_clients:
6058
php8_fpm_pool_pm: dynamic
6159
php8_fpm_pool_pm_max_children: 5
6260
php8_fpm_pool_pm_start_servers: 2
@@ -67,17 +65,17 @@ php8_fpm_pool_pm_max_requests: 512
6765
php8_fpm_pool_status_path: /status
6866
php8_fpm_pool_ping_path: /ping
6967
php8_fpm_pool_ping_response: pong
70-
php8_fpm_pool_access_log: ~
71-
php8_fpm_pool_access_format: ~
72-
php8_fpm_pool_slowlog: ~
68+
php8_fpm_pool_access_log:
69+
php8_fpm_pool_access_format:
70+
php8_fpm_pool_slowlog:
7371
php8_fpm_pool_request_slowlog_timeout: 0
7472
php8_fpm_pool_request_terminate_timeout: 0
75-
php8_fpm_pool_rlimit_files: ~
76-
php8_fpm_pool_rlimit_core: ~
77-
php8_fpm_pool_chroot: ~
73+
php8_fpm_pool_rlimit_files:
74+
php8_fpm_pool_rlimit_core:
75+
php8_fpm_pool_chroot:
7876
php8_fpm_pool_chdir: /var/www
79-
php8_fpm_pool_catch_workers_output: yes
80-
php8_fpm_pool_clear_env: yes
77+
php8_fpm_pool_catch_workers_output: true
78+
php8_fpm_pool_clear_env: true
8179
php8_fpm_pool_security_limit_extensions: .php
8280
php8_fpm_pool_env: {}
8381
php8_fpm_pool_php_admin_value: {}
Binary file not shown.

handlers/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
---
2-
32
- name: Restart Apache
4-
service:
3+
ansible.builtin.service:
54
name: apache2
65
state: restarted
76
when: php8_enable_apache | bool
87

98
- name: Restart PHP FPM
10-
service:
9+
ansible.builtin.service:
1110
name: "php{{ php8_version }}-fpm"
1211
state: restarted
1312
when: php8_enable_fpm | bool

meta/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
galaxy_info:
44
role_name: php8
5+
namespace: f500
56
author: "Jasper N. Brouwer, Ramon de la Fuente"
67
description: Install PHP version 8.X from deb.sury.org
78
company: Future500
89
license: LGPL-3.0
910
min_ansible_version: "2.0"
1011
platforms:
11-
- name: Debian
12-
versions:
13-
- bullseye
14-
- bookworm
12+
- name: Debian
13+
versions:
14+
- bullseye
15+
- bookworm
1516
galaxy_tags:
1617
- web

0 commit comments

Comments
 (0)