Skip to content

Commit 07226f3

Browse files
Feature/issue 1/create os user (#2)
* init push with missing files * added missing quotes * linting * linting * linting * linting * linting * linting * added delete list example * added password prompt and changed user module * removed vars and added reference to binaries.yaml * added binaries vars file * linting * linting * updated README * typo * typo * added file mode for ssh/config * added file mode for sudoers file * added skip rule no-log-password * added deletion variable * init extra deletion task * added deletion task with extra vars condition * init LICENSE * changed license to apache-2.0 * example pre-tasks for password prompt (unfinished) * formatting * removed password prompt pre-task * removed * changed back to pre password-prompt version * added description * added delete task run command and ssh playbook example * linting * linting * linting * Update README.md * Update lint.yml --------- Co-authored-by: andre-ebert-sva <[email protected]>
1 parent 6807882 commit 07226f3

17 files changed

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

.github/workflows/lint.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,37 @@
1-
name: linting
1+
---
2+
name: Ansible lint
23
on:
3-
# Triggers the workflow on push or pull request events but only for the "main" branch
44
push:
5-
branches: [ "main" ]
5+
branches:
6+
- main
7+
- feature/*
8+
- fix/*
69
pull_request:
7-
branches: [ "main" ]
8-
10+
branches:
11+
- main
12+
- feature/*
13+
- fix/*
914
workflow_dispatch:
15+
1016
jobs:
11-
linting:
12-
continue-on-error: true
13-
runs-on: self-hosted
14-
steps:
15-
- uses: actions/checkout@v3
17+
yaml-lint:
18+
name: Lint yaml files
19+
uses: stuttgart-things/stuttgart-things/.github/workflows/lint-yaml.yaml@yaml-lint-1
20+
with:
21+
runs-on: ghr-create-os-user-cicd
22+
environment-name: k8s
23+
continue-error: true
24+
yamllint-version: 1
25+
lintprofile-path: .yamllint
26+
artifact-name: yaml-lint
1627

17-
- name: Ansible Lint
18-
uses: ansible/[email protected]
28+
ansible-lint:
29+
name: Lint ansible code
30+
uses: stuttgart-things/stuttgart-things/.github/workflows/lint-ansible.yaml@main # ansible-lint-24.2.1
31+
with:
32+
runs-on: ghr-create-os-user-cicd
33+
environment-name: k8s
34+
continue-error: true
35+
ansible-image: eu.gcr.io/stuttgart-things/sthings-ansible:9.3.0-1
36+
playbook: tests/test.yml
37+
needs: yaml-lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/tests/inventory

.gitlab-ci.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.yamllint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
# 80 chars should be enough, but don't fail if a line is longer
6+
line-length:
7+
max: 110
8+
level: warning
9+
indentation: enable
10+
11+
# don't bother me with this rule
12+
comments: disable
13+
comments-indentation: disable

0 commit comments

Comments
 (0)