Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

Commit 06e4bea

Browse files
authored
Add linting with ansible-lint (#12)
Fix all problems reported by ``ansible-lint`` and enable linting for pull requests and pushes to main using ``ansible-community/ansible-lint-action``.
1 parent 0554c4e commit 06e4bea

File tree

8 files changed

+105
-76
lines changed

8 files changed

+105
-76
lines changed

.ansible-lint

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
skip_list:
2+
# Using FQDN for modules (e.g. ansible.builtin.copy instead of just copy)
3+
# makes the YAML files harder to read.
4+
- fqcn-builtins
5+
# Since we only build this project locally, we are happy with the default
6+
# file permissions.
7+
- risky-file-permissions

.github/workflows/ansible-lint.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Ansible linting
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Set up GitHub workspace environment variable
10+
uses: actions/checkout@v2
11+
- name: Perform linting of Ansible files
12+
uses: ansible-community/ansible-lint-action@main

group_vars/all.yml

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
title: Active Directory Certificate Services
22
link: https://atea.se
33
theme: guzzle_sphinx_theme
4-
#system_description: Provide X.509 certificates for Windows workstations and employees at Atea.
4+
# system_description: Provide X.509 certificates for Windows workstations and employees at Atea.
55
consultant:
66
name: Foo Foobarsson
77
company: Atea Sverige AB
@@ -33,7 +33,7 @@ smtp_exit_module:
3333
# - NTLM
3434
# - Kerberos
3535
method: Basic
36-
use_tls: Yes
36+
use_tls: true
3737
port: 465
3838
account:
3939
username: user
@@ -63,7 +63,7 @@ servers:
6363
existing_backup: Z:\app-RootCA\Backup
6464
policy:
6565
high_serial: 0xFFFFFFFF
66-
keep_expired_certificates_on_crl: No
66+
keep_expired_certificates_on_crl: false
6767
# Possible choices are:
6868
# - RSA4096
6969
# - P256
@@ -80,15 +80,15 @@ servers:
8080
gateway: 192.168.56.1
8181
os: Windows Server 2022
8282
dcom_port: 4000
83-
web_enrollment: Yes
84-
smtp_exit_module: Yes
83+
web_enrollment: true
84+
smtp_exit_module: true
8585
location:
8686
log: C:\Log
8787
database: C:\Database
8888
existing_backup: Z:\app-IssuingCA1\Backup
8989
policy:
9090
high_serial: 0xFFFFFFFF
91-
keep_expired_certificates_on_crl: No
91+
keep_expired_certificates_on_crl: false
9292
# Possible choices are:
9393
# - RSA4096
9494
# - P256
@@ -106,15 +106,15 @@ servers:
106106
gateway: 192.168.56.1
107107
os: Windows Server 2022
108108
dcom_port: 4000
109-
web_enrollment: Yes
110-
smtp_exit_module: Yes
109+
web_enrollment: true
110+
smtp_exit_module: true
111111
location:
112112
log: C:\Log
113113
database: C:\Database
114114
existing_backup: Z:\app-IssuingCA1\Backup
115115
policy:
116116
high_serial: 0xFFFFFFFF
117-
keep_expired_certificates_on_crl: No
117+
keep_expired_certificates_on_crl: false
118118
# Possible choices are:
119119
# - RSA4096
120120
# - P256
@@ -145,32 +145,32 @@ templates:
145145
description: Certificate for workstations in the domain.
146146
validity: 365
147147
renewal_period: 90
148-
publish: No
149-
use_ec: Yes
148+
publish: false
149+
use_ec: true
150150
groups:
151151
- name: Domain Computers
152-
autoenroll: Yes
152+
autoenroll: true
153153
subject:
154-
email: No
155-
dnsname: Yes
156-
upn: No
154+
email: false
155+
dnsname: true
156+
upn: false
157157
- from: User
158158
name: Atea User
159159
description: Certificate for users in the domain.
160160
validity: 365
161161
renewal_period: 90
162-
publish: Yes
163-
use_ec: Yes
162+
publish: true
163+
use_ec: true
164164
groups:
165165
- name: Domain Users
166-
autoenroll: Yes
166+
autoenroll: true
167167
subject:
168-
email: Yes
169-
dnsname: No
170-
upn: Yes
168+
email: true
169+
dnsname: false
170+
upn: true
171171
- name: Legacy User
172172
description: Legacy template for users.
173173
- name: Legacy Computer
174174
description: Legacy template for computers.
175175
autoenrollment:
176-
gpo: PKI-GPO
176+
gpo: PKI-GPO

playbook.yml

+25-17
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
- name: Build ADCS documentation
22
hosts: localhost
3-
gather_facts: False
3+
gather_facts: false
44
pre_tasks:
55
- name: Check if the Naming and Profile Document can be generated
66
stat:
77
path: files/naming_document
88
register: naming_document_data
99
tasks:
10-
- block:
11-
- name: Create release directory
12-
file:
13-
path: "release"
14-
state: directory
15-
- name: Create Naming and Profile Document
16-
include_role:
17-
name: naming_document
18-
when: naming_document_data.stat.exists
19-
- name: Create installation manual
20-
include_role:
21-
name: installation_manual
22-
- name: Create operations manual
23-
include_role:
24-
name: operations_manual
10+
- name: Execute tasks and roles
11+
block:
12+
- name: Get shortened commit hash
13+
command:
14+
# The git module cannot be used here
15+
# noqa: command-instead-of-module
16+
cmd: git rev-parse --short HEAD
17+
register: short_commit_hash
18+
changed_when: false
19+
- name: Create release directory
20+
file:
21+
path: release
22+
state: directory
23+
- name: Create Naming and Profile Document
24+
include_role:
25+
name: naming_document
26+
when: naming_document_data.stat.exists
27+
- name: Create installation manual
28+
include_role:
29+
name: installation_manual
30+
- name: Create operations manual
31+
include_role:
32+
name: operations_manual
2533
rescue:
2634
- name: Cleaning up
2735
file:
@@ -32,4 +40,4 @@
3240
- roles/operations_manual/_docs
3341
- roles/naming_document/_docs
3442
loop_control:
35-
loop_var: docs
43+
loop_var: docs

roles/installation_manual/tasks/main.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
- name: Get shortened commit hash
2-
command:
3-
cmd: git rev-parse --short HEAD
4-
register: short_commit_hash
51
- name: Generate a secret
62
set_fact:
73
secret: "{{ lookup('password', '/dev/null length=16') }}"
@@ -35,6 +31,7 @@
3531
- name: Perform RST linting
3632
command:
3733
cmd: doc8 --max-line-length 2000 "{{ role_path }}/_docs/chapters"
34+
changed_when: false
3835
- name: Copy graphics
3936
copy:
4037
src: "{{ item }}"
@@ -47,10 +44,11 @@
4744
dest: '{{ role_path }}/_docs/diagrams/{{ item | basename | regex_replace("\.j2$", "") }}'
4845
with_fileglob: templates/diagrams/*.py.j2
4946
- name: Render diagrams
50-
shell: python3 {{ item }}
47+
command: python3 {{ item }}
5148
args:
5249
chdir: "{{ role_path }}/_docs/diagrams"
5350
with_fileglob: "{{ role_path }}/_docs/diagrams/*.py"
51+
changed_when: true
5452
- name: Create Sphinx configuration
5553
template:
5654
src: conf.py.j2
@@ -65,9 +63,10 @@
6563
- atea.png
6664
- atea_aligned.png
6765
- name: Create style for Microsoft Word
68-
shell: python3 render.py
66+
command: python3 render.py
6967
args:
7068
chdir: "{{ role_path }}/files/docxbuilder"
69+
changed_when: true
7170
- name: Copy style for Microsoft Word
7271
copy:
7372
src: style.docx
+17-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
extras:
22
naming_and_profile_document:
3-
include_ldif: Yes
4-
include_ca_certs: Yes
3+
include_ldif: true
4+
include_ca_certs: true
55
templates:
6-
- name: Atea Computer
7-
description: Certificate used to authenticate workstations at Atea.
8-
# https://diagrams.mingrammer.com/docs/nodes/generic
9-
# For example:
10-
#
11-
# Mobile: diagrams.generic.device.Mobile
12-
# Client: diagrams.onprem.client.Client
13-
# User: diagrams.onprem.client.User
14-
class: diagrams.onprem.client.User
15-
- name: Atea User
16-
description: Certificate used to authenticate employees at Atea.
6+
- name: Atea Computer
7+
description: Certificate used to authenticate workstations at Atea.
8+
# https://diagrams.mingrammer.com/docs/nodes/generic
9+
# For example:
10+
#
11+
# Mobile: diagrams.generic.device.Mobile
12+
# Client: diagrams.onprem.client.Client
13+
# User: diagrams.onprem.client.User
14+
class: diagrams.onprem.client.User
15+
- name: Atea User
16+
description: Certificate used to authenticate employees at Atea.
1717
certificate_authorities:
18-
- name: R1
19-
description: Trust anchor for Atea's public key infrastructure.
20-
- name: ICA1
21-
description: Issuing CA for Atea's public key infrastructure.
18+
- name: R1
19+
description: Trust anchor for Atea's public key infrastructure.
20+
- name: ICA1
21+
description: Issuing CA for Atea's public key infrastructure.

roles/naming_document/tasks/main.yml

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
- name: Get shortened commit hash
2-
command:
3-
cmd: git rev-parse --short HEAD
4-
register: short_commit_hash
51
- name: Create directory structure
62
file:
73
state: directory
@@ -18,13 +14,20 @@
1814
with_fileglob:
1915
- "graphics/*.png"
2016
- name: Parse LDIF configuration
21-
shell:
22-
cmd: python3 {{ role_path }}/files/parse.py --file {{ playbook_dir }}/files/naming_document/Configuration.ldf
17+
command:
18+
cmd: >
19+
python3 {{ role_path }}/files/parse.py
20+
--file {{ playbook_dir }}/files/naming_document/Configuration.ldf
2321
register: public_key_services_configuration
22+
changed_when: true
2423
- name: Extract certificate templates from configuration
25-
shell:
26-
cmd: python3 "{{ role_path }}/roles/naming_document/extract_templates.py --file {{ playbook_dir }}/files/Configuration.ldf --output-directory {{ playbook_dir }}/files/naming_document/ldif
24+
command:
25+
cmd: >
26+
python3 "{{ role_path }}/roles/naming_document/extract_templates.py
27+
--file {{ playbook_dir }}/files/Configuration.ldf
28+
--output-directory {{ playbook_dir }}/files/naming_document/ldif
2729
when: extras.naming_and_profile_document.include_ldif | default(false)
30+
changed_when: true
2831
- name: Create index from template
2932
template:
3033
src: index.rst.j2
@@ -38,15 +41,17 @@
3841
- name: Perform RST linting
3942
command:
4043
cmd: doc8 --max-line-length 2000 "{{ role_path }}/_docs/chapters"
44+
changed_when: false
4145
- name: Copy diagrams scripts
4246
template:
4347
src: "{{ item }}"
4448
dest: '{{ role_path }}/_docs/diagrams/{{ item | basename | regex_replace("\.j2$", "") }}'
4549
with_fileglob: templates/diagrams/*.py.j2
4650
- name: Render diagrams
47-
shell: python3 {{ item }}
51+
command: python3 {{ item }}
4852
args:
4953
chdir: "{{ role_path }}/_docs/diagrams"
54+
changed_when: true
5055
with_fileglob: "{{ role_path }}/_docs/diagrams/*.py"
5156
- name: Create Sphinx configuration
5257
template:

roles/operations_manual/tasks/main.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
- name: Get shortened commit hash
2-
command:
3-
cmd: git rev-parse --short HEAD
4-
register: short_commit_hash
51
- name: Create directory structure
62
file:
73
state: directory
@@ -23,6 +19,7 @@
2319
- name: Perform RST linting
2420
command:
2521
cmd: doc8 --max-line-length 2000 "{{ role_path }}/_docs/chapters"
22+
changed_when: false
2623
- name: Copy graphics
2724
copy:
2825
src: "{{ item }}"
@@ -43,9 +40,10 @@
4340
- atea.png
4441
- atea_aligned.png
4542
- name: Create style for Microsoft Word
46-
shell: python3 render.py
43+
command: python3 render.py
4744
args:
4845
chdir: "{{ role_path }}/files/docxbuilder"
46+
changed_when: true
4947
- name: Copy style for Microsoft Word
5048
copy:
5149
src: style.docx

0 commit comments

Comments
 (0)