Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit 96f76a9

Browse files
authored
Feature/test vagrant (#8)
* add Vagrant driver for a larger test coverage. * Update build environment. * Bug in token provisioning for worker instances fixed. * update README * update molecule config
1 parent 69d7b99 commit 96f76a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1620
-92
lines changed

.ansible-lint

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33
skip_list:
44
- name[casing]
55
- name[template]
6-
7-
...

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ insert_final_newline = true
1616
max_line_length = 100
1717

1818
[*.py]
19+
indent_style = space
1920
indent_size = 4
2021

2122
[*.md]
2223
trim_trailing_whitespace = false
23-

.flake8

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
[flake8]
22

3+
# E221 multiple spaces before operator
4+
# E251 unexpected spaces around keyword / parameter equals
5+
6+
ignore = E221,E251
7+
38
exclude =
49
# No need to traverse our git directory
510
.git,
611
# There's no value in checking cache directories
712
__pycache__,
813
.tox
914

10-
1115
# E203: https://github.com/python/black/issues/315
1216
# ignore = D,E741,W503,W504,H,E501,E203
1317

1418
max-line-length = 195
19+

.github/workflows/main.yml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,14 @@ jobs:
5252
python -m pip install --upgrade pip
5353
pip install -r test-requirements.txt
5454
55-
# See: https://github.com/geerlingguy/ansible-role-mysql/issues/422
56-
- name: Disable AppArmor
57-
run: |
58-
set -x
59-
sudo apt-get install apparmor-profiles
60-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
61-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
62-
6355
- name: test with tox
6456
run: |
65-
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
66-
-- molecule test --scenario-name default
57+
make \
58+
test \
59+
-e TOX_SCENARIO="${{ matrix.scenario }}" \
60+
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
61+
-e DISTRIBUTION="${{ matrix.image }}"
62+
6763
env:
6864
PY_COLORS: '1'
6965
ANSIBLE_FORCE_COLOR: '1'
@@ -101,18 +97,13 @@ jobs:
10197
python -m pip install --upgrade pip
10298
pip install -r test-requirements.txt
10399
104-
# See: https://github.com/geerlingguy/ansible-role-mysql/issues/422
105-
- name: Disable AppArmor
106-
run: |
107-
set -x
108-
sudo apt-get install apparmor-profiles
109-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
110-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
111-
112100
- name: test with tox
113101
run: |
114-
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
115-
-- molecule test --scenario-name default
102+
make \
103+
test \
104+
-e TOX_SCENARIO="${{ matrix.scenario }}" \
105+
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
106+
-e DISTRIBUTION="${{ matrix.image }}"
116107
env:
117108
PY_COLORS: '1'
118109
ANSIBLE_FORCE_COLOR: '1'

.github/workflows/multi-controller.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
ansible-version:
3333
- '6.1'
3434
scenario:
35-
- default
35+
- multi-controller
3636

3737
steps:
3838
- name: check out the codebase.
@@ -50,18 +50,14 @@ jobs:
5050
python -m pip install --upgrade pip
5151
pip install -r test-requirements.txt
5252
53-
# See: https://github.com/geerlingguy/ansible-role-mysql/issues/422
54-
- name: Disable AppArmor
55-
run: |
56-
set -x
57-
sudo apt-get install apparmor-profiles
58-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
59-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
60-
6153
- name: test with tox
6254
run: |
63-
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
64-
-- molecule test --scenario-name multi-controller
55+
make \
56+
test \
57+
-e TOX_SCENARIO="${{ matrix.scenario }}" \
58+
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
59+
-e DISTRIBUTION="${{ matrix.image }}"
60+
6561
env:
6662
PY_COLORS: '1'
6763
ANSIBLE_FORCE_COLOR: '1'

.github/workflows/multi-worker.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
ansible-version:
3333
- '6.1'
3434
scenario:
35-
- default
35+
- multi-worker
3636

3737
steps:
3838
- name: check out the codebase.
@@ -50,18 +50,14 @@ jobs:
5050
python -m pip install --upgrade pip
5151
pip install -r test-requirements.txt
5252
53-
# See: https://github.com/geerlingguy/ansible-role-mysql/issues/422
54-
- name: Disable AppArmor
55-
run: |
56-
set -x
57-
sudo apt-get install apparmor-profiles
58-
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
59-
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
60-
6153
- name: test with tox
6254
run: |
63-
tox -e ansible_$(printf "${{ matrix.ansible-version }}") \
64-
-- molecule test --scenario-name multi-worker
55+
make \
56+
test \
57+
-e TOX_SCENARIO="${{ matrix.scenario }}" \
58+
-e TOX_ANSIBLE="ansible_${{ matrix.ansible-version }}" \
59+
-e DISTRIBUTION="${{ matrix.image }}"
60+
6561
env:
6662
PY_COLORS: '1'
6763
ANSIBLE_FORCE_COLOR: '1'

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
.tox
2-
__pycache__
32
.galaxy_install_info
3+
*kate-swp
4+
__pycache__
5+
.cache
6+
.directory

.yamllint

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
---
2+
# Based on ansible-lint config
23
extends: default
4+
35
rules:
4-
line-length:
5-
max: 195
6-
level: warning
76
braces:
8-
min-spaces-inside: 0
97
max-spaces-inside: 1
8+
level: error
109
brackets:
11-
min-spaces-inside: 0
1210
max-spaces-inside: 1
13-
indentation:
14-
spaces: 2
11+
level: error
12+
colons:
13+
max-spaces-after: -1
14+
level: error
15+
commas:
16+
max-spaces-after: -1
17+
level: error
1518
comments: disable
1619
comments-indentation: disable
20+
document-start: disable
21+
empty-lines:
22+
max: 3
23+
level: error
24+
hyphens:
25+
level: error
26+
indentation:
27+
spaces: 2
28+
key-duplicates: enable
29+
line-length:
30+
max: 195
31+
level: warning
32+
new-line-at-end-of-file: disable
33+
new-lines:
34+
type: unix
35+
trailing-spaces: disable
1736
truthy: disable
1837

1938
ignore: |
20-
tests/
2139
molecule/
22-
.molecule/
23-
.travis.yml
24-
.tox/
25-
.github/
26-
k0s_example.yaml
27-
templates/k0s/k0s_1.25.2.yml
40+
.github

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#
22
export TOX_SCENARIO ?= default
3-
# export TOX_PYTHON ?= py310
43
export TOX_ANSIBLE ?= ansible_6.1
54

65
.PHONY: converge destroy verify lint
76

87
default: converge
98

9+
test:
10+
@hooks/test
11+
1012
converge:
1113
@hooks/converge
1214

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,29 @@ Use vanilla upstream Kubernetes distro [k0s](https://github.com/k0sproject/k0s).
88
Similar to [movd/k0s-ansible](https://github.com/movd/k0s-ansible), **but** better (i think so ;) )
99

1010

11-
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/bodsch/ansible-k0s/CI)][ci]
11+
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/bodsch/ansible-k0s/main.yml?branch=main)][ci]
1212
[![GitHub issues](https://img.shields.io/github/issues/bodsch/ansible-k0s)][issues]
1313
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/bodsch/ansible-k0s)][releases]
14+
[![Ansible Quality Score](https://img.shields.io/ansible/quality/50067?label=role%20quality)][quality]
1415

1516
[ci]: https://github.com/bodsch/ansible-k0s/actions
1617
[issues]: https://github.com/bodsch/ansible-k0s/issues?q=is%3Aopen+is%3Aissue
1718
[releases]: https://github.com/bodsch/ansible-k0s/releases
19+
[quality]: https://galaxy.ansible.com/bodsch/k0s
20+
21+
22+
If `latest` is set for `k0s_version`, the role tries to install the latest release version.
23+
**Please use this with caution, as incompatibilities between releases may occur!**
24+
25+
The binaries are installed below `/usr/local/bin/k0s/${k0s_version}` and later linked to `/usr/bin`.
26+
This should make it possible to downgrade relatively safely.
27+
28+
The k0s archive is stored on the Ansible controller, unpacked and then the binaries are copied to the target system.
29+
The cache directory can be defined via the environment variable `CUSTOM_LOCAL_TMP_DIRECTORY`.
30+
By default it is `${HOME}/.cache/ansible/k0s`.
31+
If this type of installation is not desired, the download can take place directly on the target system.
32+
However, this must be explicitly activated by setting `k0s_direct_download` to `true`.
33+
1834

1935

2036
## Why better?
@@ -39,9 +55,24 @@ Tested on
3955

4056
## working implementation
4157

42-
The example of a working implementation can be viewed at [GitLab](https://gitlab.com/kubernetes-cluser).
58+
The example of a working implementation can be viewed at [GitLab](https://gitlab.com/integration-tests/k0s).
4359
A suitable infrastructure based on KVM and Terraform can be created in the repository.
4460

61+
There are some tests in `molecule` that could be used.
62+
For reasons that are not clear to me, the tests in a docker container are not very meaningful.
63+
I have therefore extended the tests with the *Vagrant* driver.
64+
65+
There is a `Makefile` to start the tests:
66+
67+
```shell
68+
make test -e TOX_SCENARIO=multi-worker
69+
```
70+
71+
72+
```shell
73+
make test -e TOX_SCENARIO=vagrant-multi-worker
74+
```
75+
4576

4677
## Contribution
4778

@@ -52,7 +83,7 @@ Please read [Contribution](CONTRIBUTING.md)
5283

5384
The `master` Branch is my *Working Horse* includes the "latest, hot shit" and can be complete broken!
5485

55-
If you want to use something stable, please use a [Tagged Version](https://gitlab.com/bodsch/ansible-k0s/-/tags)!
86+
If you want to use something stable, please use a [Tagged Version](https://github.com/bodsch/ansible-k0s/tags)!
5687

5788

5889
## usage

0 commit comments

Comments
 (0)