Skip to content

Commit 04dab73

Browse files
authored
Merge pull request #3 from f500/ansible-lint
Add ansible lint pr workflow
2 parents af65b34 + 97ab544 commit 04dab73

File tree

6 files changed

+180
-12
lines changed

6 files changed

+180
-12
lines changed

.ansible-lint

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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+
- yaml[line-length]
55+
# - skip_this_tag
56+
57+
# Ansible-lint does not automatically load rules that have the 'opt-in' tag.
58+
# You must enable opt-in rules by listing each rule 'id' below.
59+
enable_list:
60+
- args
61+
- empty-string-compare # opt-in
62+
- no-log-password # opt-in
63+
- no-same-owner # opt-in
64+
- name[prefix] # opt-in
65+
- galaxy-version-incorrect # opt-in
66+
# add yaml here if you want to avoid ignoring yaml checks when yamllint
67+
# library is missing. Normally its absence just skips using that rule.
68+
- yaml
69+
# Report only a subset of tags and fully ignore any others
70+
# tags:
71+
# - jinja[spacing]
72+
73+
# Ansible-lint does not fail on warnings from the rules or tags listed below
74+
#warn_list:
75+
# - skip_this_tag
76+
# - experimental # experimental is included in the implicit list
77+
# - role-name
78+
# - yaml[document-start] # you can also use sub-rule matches
79+
80+
# Some rules can transform files to fix (or make it easier to fix) identified
81+
# errors. `ansible-lint --fix` will reformat YAML files and run these transforms.
82+
# By default it will run all transforms (effectively `write_list: ["all"]`).
83+
# You can disable running transforms by setting `write_list: ["none"]`.
84+
# Or only enable a subset of rule transforms by listing rules/tags here.
85+
# write_list:
86+
# - all
87+
88+
# Offline mode disables installation of requirements.yml and schema refreshing
89+
offline: true
90+
91+
# Define required Ansible's variables to satisfy syntax check
92+
#extra_vars:
93+
# foo: bar
94+
# multiline_string_variable: |
95+
# line1
96+
# line2
97+
# complex_variable: ":{;\t$()"
98+
99+
# Uncomment to enforce action validation with tasks, usually is not
100+
# needed as Ansible syntax check also covers it.
101+
# skip_action_validation: false
102+
103+
# List of additional kind:pattern to be added at the top of the default
104+
# match list, first match determines the file kind.
105+
#kinds:
106+
# - playbook: "**/examples/*.{yml,yaml}"
107+
# - galaxy: "**/folder/galaxy.yml"
108+
# - tasks: "**/tasks/*.yml"
109+
# - vars: "**/vars/*.yml"
110+
# - meta: "**/meta/main.yml"
111+
# - yaml: "**/*.yaml-too"
112+
113+
# List of additional collections to allow in only-builtins rule.
114+
# only_builtins_allow_collections:
115+
# - example_ns.example_collection
116+
117+
# List of additions modules to allow in only-builtins rule.
118+
# only_builtins_allow_modules:
119+
# - example_module
120+
121+
# Allow setting custom prefix for name[prefix] rule
122+
#task_name_prefix: "{stem} | "
123+
# Complexity related settings
124+
125+
# Limit the depth of the nested blocks:
126+
# max_block_depth: 20
127+
128+
# Also recognize these versions of Ansible as supported:
129+
# supported_ansible_also:
130+
# - "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
@@ -15,6 +15,22 @@ Example Playbook
1515
roles:
1616
- { role: f500.vim }
1717

18+
Linting
19+
-------
20+
Github actions will check this role with ansible-lint. To run this locally, you will need to follow the following steps:
21+
22+
```bash
23+
brew install ansible-lint
24+
brew install yamllint
25+
ansible-lint
26+
```
27+
28+
to fix the linting errors, run:
29+
30+
```bash
31+
ansible-lint --fix
32+
```
33+
1834
License
1935
-------
2036

meta/main.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
galaxy_info:
33
author: "Jasper N. Brouwer, Ramon de la Fuente"
44
role_name: vim
5+
namespace: "f500"
56
description: "Install Vim, set vimrc and use update-alternatives to add vim"
67
company: Future500
78
license: LGPL-3.0
8-
min_ansible_version: 1.6
9+
min_ansible_version: "1.6"
910
platforms:
10-
- name: Debian
11-
versions:
12-
- bullseye
13-
- bookworm
11+
- name: Debian
12+
versions:
13+
- bullseye
14+
- bookworm
1415
galaxy_tags:
1516
- system
1617
dependencies: []

tasks/main.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
---
2+
- name: Install vim
3+
ansible.builtin.apt:
4+
pkg: vim
5+
state: present
26

3-
- name: install vim
4-
apt: pkg=vim state=present
7+
- name: Write vimrc
8+
ansible.builtin.copy:
9+
src: vimrc
10+
dest: /etc/vim/vimrc
11+
owner: root
12+
group: root
13+
mode: "0644"
514

6-
- name: write vimrc
7-
copy: src=vimrc dest=/etc/vim/vimrc owner=root group=root mode=0644
8-
9-
- name: set vim alternatives
10-
alternatives: "name={{ item }} path=/usr/bin/vim.basic"
15+
- name: Set vim alternatives
16+
community.general.alternatives:
17+
name: "{{ item }}"
18+
path: "/usr/bin/vim.basic"
1119
with_items: [editor, ex, rview, rvim, vi, view, vim, vimdiff]

0 commit comments

Comments
 (0)