Skip to content

Commit 3fa78c5

Browse files
committed
For testing setup snapshot.
1 parent eebf471 commit 3fa78c5

11 files changed

Lines changed: 75 additions & 221 deletions

File tree

tasks/main.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,14 @@
55
# An example of how to set distribution and version specific internal variables
66
# (defined in vars/ directory):
77
- name: Set version specific variables
8-
include_vars: "{{ item }}"
9-
with_first_found:
10-
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
11-
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
12-
- "{{ ansible_distribution }}.yml"
13-
- "{{ ansible_os_family }}.yml"
14-
- "default.yml"
8+
include_tasks: set_vars.yml
159

1610
# Examples of some tasks:
1711
- name: Ensure required packages are installed
1812
package:
1913
name: "{{ __template_packages }}"
2014
state: present
2115

22-
- name: use crypttab
23-
crypttab:
24-
25-
- name: use firewalld
26-
firewalld:
27-
28-
- name: use ipaddr
29-
debug:
30-
msg: ipaddr {{ '127.0.0.1' | ipaddr }}
31-
32-
- name: use json_query
33-
debug:
34-
msg: json_query {{ ansible_facts | json_query('name') }}
35-
3616
- name: Ensure required services are enabled and started
3717
service:
3818
name: "{{ item }}"

tasks/set_vars.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
- name: Ensure ansible_facts used by role
3+
setup:
4+
gather_subset: min
5+
when: not ansible_facts.keys() | list |
6+
intersect(__citest_required_facts) == __citest_required_facts
7+
8+
- name: Set platform/version specific variables
9+
include_vars: "{{ __vars_file }}"
10+
loop:
11+
- "{{ ansible_facts['os_family'] }}.yml"
12+
- "{{ ansible_facts['distribution'] }}.yml"
13+
- >-
14+
{{ ansible_facts['distribution'] ~ '-' ~
15+
ansible_facts['distribution_major_version'] }}.yml
16+
- >-
17+
{{ ansible_facts['distribution'] ~ '-' ~
18+
ansible_facts['distribution_version'] }}.yml
19+
vars:
20+
__vars_file: "{{ role_path }}/vars/{{ item }}"
21+
when: __vars_file is file

tests/setup-snapshot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
- hosts: all
2+
tasks:
3+
- name: Set platform/version specific variables
4+
include_role:
5+
name: linux-system-roles.ci-testing
6+
tasks_from: set_vars.yml
7+
public: true
8+
9+
- name: Install test packages
10+
package:
11+
name: "{{ __template_packages }}"
12+
state: present

tests/tests_another.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: MIT
2+
---
3+
- name: Ensure that the role runs with default parameters
4+
hosts: all
5+
6+
vars:
7+
template_foo: "foo2"
8+
template_bar: "bar2"
9+
tasks:
10+
- name: default run
11+
include_role:
12+
name: linux-system-roles.ci-testing

tests/tests_default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55

66
roles:
77
- linux-system-roles.ci-testing
8+
gather_facts: false

tox.ini

Lines changed: 6 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -1,200 +1,9 @@
11
# SPDX-License-Identifier: MIT
2-
[tox]
3-
envlist =
4-
black, pylint, flake8, yamllint
5-
py{26,27,36,37,38},
6-
custom
7-
skipsdist = true
8-
skip_missing_interpreters = true
2+
[lsr_config]
3+
lsr_enable = true
94

10-
[testenv]
11-
passenv = *
12-
basepython = python3
13-
changedir = {toxinidir}/tests
14-
# List common dependencies for Python interpreters here:
15-
setenv =
16-
PYTHONPATH = {toxinidir}/library:{toxinidir}/module_utils
17-
LC_ALL = C.UTF-8
18-
SRC_MODULE_UTILS_DIR = {envsitepackagesdir}/ansible/module_utils
19-
DEST_MODULE_UTILS_DIR = {toxinidir}/module_utils
20-
deps =
21-
py{26,27,36,37,38}: pytest-cov
22-
py{27,36,37,38}: pytest>=3.5.1
23-
py26: pytest
24-
py{26,27,36,37,38}: -rpytest_extra_requirements.txt
25-
whitelist_externals =
26-
bash
27-
commands =
28-
bash {toxinidir}/.travis/runpytest.sh \
29-
--durations=5 \
30-
--cov={toxinidir}/library --cov={toxinidir}/module_utils \
31-
--cov-report=html:htmlcov-{envname} \
32-
--cov-report=term \
33-
{posargs} \
34-
unit
5+
[lsr_ansible-lint]
6+
configfile = {toxinidir}/.ansible-lint
357

36-
[base]
37-
38-
[testenv:py26]
39-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.6}
40-
install_command =
41-
pip install {opts} {packages}
42-
list_dependencies_command =
43-
pip freeze
44-
basepython = python2.6
45-
46-
[testenv:py27]
47-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}
48-
basepython = python2.7
49-
50-
[testenv:py36]
51-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:3.6}
52-
basepython = python3.6
53-
54-
[testenv:py37]
55-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:3.7}
56-
basepython = python3.7
57-
58-
[testenv:py38]
59-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:3.8}
60-
basepython = python3.8
61-
62-
[testenv:black]
63-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:3.6}
64-
basepython = python3.6
65-
passenv = RUN_BLACK_*
66-
changedir = {toxinidir}
67-
deps =
68-
black
69-
commands =
70-
bash {toxinidir}/.travis/runblack.sh --check --diff .
71-
72-
[testenv:pylint]
73-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}
74-
basepython = python2.7
75-
passenv = RUN_PYLINT_*
76-
changedir = {toxinidir}
77-
deps =
78-
ansible
79-
colorama
80-
pylint>=1.8.4
81-
-rpylint_extra_requirements.txt
82-
commands =
83-
bash {toxinidir}/.travis/runpylint.sh --errors-only {posargs}
84-
85-
[testenv:flake8]
86-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:2.7}
87-
basepython = python2.7
88-
passenv = RUN_FLAKE8_*
89-
changedir = {toxinidir}
90-
deps =
91-
flake8>=3.5
92-
commands =
93-
bash {toxinidir}/.travis/runflake8.sh {posargs} .
94-
95-
[testenv:yamllint]
96-
changedir = {toxinidir}
97-
deps = yamllint
98-
commands = yamllint .
99-
100-
[testenv:coveralls]
101-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:coveralls}
102-
passenv = TRAVIS TRAVIS_*
103-
deps =
104-
coveralls
105-
commands =
106-
bash {toxinidir}/.travis/runcoveralls.sh {posargs}
107-
108-
[molecule_common]
109-
changedir = {toxinidir}
110-
deps =
111-
ansible-lint==4.3.5
112-
{env:LSR_ANSIBLE_DEP:ansible}
113-
docker
114-
molecule<3
115-
selinux
116-
wcwidth==0.1.9;python_version=="3.6"
117-
-rmolecule_extra_requirements.txt
118-
runsyspycmd = {toxinidir}/.travis/runsyspycmd.sh
119-
120-
[testenv:molecule_version]
121-
changedir = {[molecule_common]changedir}
122-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
123-
deps =
124-
{[molecule_common]deps}
125-
commands =
126-
bash {[molecule_common]runsyspycmd} molecule --version
127-
bash {[molecule_common]runsyspycmd} ansible --version
128-
129-
[testenv:molecule_lint]
130-
changedir = {[molecule_common]changedir}
131-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
132-
deps =
133-
{[molecule_common]deps}
134-
commands =
135-
bash {[molecule_common]runsyspycmd} \
136-
molecule lint -s {env:LSR_MSCENARIO:default} {posargs}
137-
138-
[testenv:molecule_syntax]
139-
changedir = {[molecule_common]changedir}
140-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
141-
deps =
142-
{[molecule_common]deps}
143-
commands =
144-
bash {[molecule_common]runsyspycmd} \
145-
molecule syntax -s {env:LSR_MSCENARIO:default} {posargs}
146-
147-
[testenv:molecule_test]
148-
changedir = {[molecule_common]changedir}
149-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
150-
deps =
151-
{[molecule_common]deps}
152-
commands =
153-
bash {[molecule_common]runsyspycmd} \
154-
molecule test -s {env:LSR_MSCENARIO:default} {posargs}
155-
156-
[testenv:molecule]
157-
changedir = {[molecule_common]changedir}
158-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:molecule}
159-
deps =
160-
{[molecule_common]deps}
161-
commands =
162-
{[testenv:molecule_version]commands}
163-
{[testenv:molecule_lint]commands}
164-
{[testenv:molecule_syntax]commands}
165-
{[testenv:molecule_test]commands}
166-
167-
[testenv:custom]
168-
changedir = {toxinidir}
169-
envdir = {toxworkdir}/env-{env:TRAVIS_PYTHON_VERSION:custom}
170-
deps =
171-
-rcustom_requirements.txt
172-
commands =
173-
bash {toxinidir}/.travis/custom.sh
174-
175-
[pytest]
176-
addopts = -rxs
177-
178-
[flake8]
179-
show_source = true
180-
max-line-length = 88
181-
ignore = E402,W503
182-
exclude = .venv,.tox
183-
statistics = true
184-
#verbose = 3
185-
186-
[pylint]
187-
max-line-length = 88
188-
disable = wrong-import-position
189-
190-
[pycodestyle]
191-
max-line-length = 88
192-
193-
[travis]
194-
python =
195-
2.6: py26,coveralls,custom
196-
2.7: py27,coveralls,flake8,pylint,custom
197-
3.6: py36,coveralls,black,yamllint,custom
198-
3.7: py37,coveralls,custom
199-
3.8: py38,coveralls,custom
200-
3.8-dev: py38,coveralls,custom
8+
[lsr_pylint]
9+
configfile = {toxinidir}/pylintrc

vars/CentOS-6.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Put internal variables here with CentOS 6 specific values.
44

55
# Example:
6-
__template_packages: []
6+
__template_packages: [python2]
77
__template_services: []

vars/CentOS-7.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Put internal variables here with CentOS 7 specific values.
44

55
# Example:
6-
__template_packages: []
6+
__template_packages: [python2]
77
__template_services: []

vars/default.yml renamed to vars/CentOS-8.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Put internal variables here with values for unrecognized distributions.
44

55
# Example:
6-
__template_packages: []
6+
__template_packages: [python3]
77
__template_services: []

vars/RedHat-8.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: MIT
2+
---
3+
# Put internal variables here with values for unrecognized distributions.
4+
5+
# Example:
6+
__template_packages: [python3]
7+
__template_services: []

0 commit comments

Comments
 (0)