Skip to content

Commit

Permalink
Merge branch 'main' into add_quoted_test
Browse files Browse the repository at this point in the history
  • Loading branch information
ziegenberg authored Jun 7, 2023
2 parents 75fd408 + 600f71a commit dd0ab36
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .config/requirements-lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# pip-compile --no-annotate --output-file=.config/requirements-lock.txt --resolver=backtracking --strip-extras --unsafe-package=ruamel-yaml-clib pyproject.toml
#
ansible-compat==3.0.2
ansible-compat==4.1.2
ansible-core==2.14.4
arrow==1.2.3
attrs==23.1.0
Expand All @@ -16,7 +16,7 @@ charset-normalizer==3.1.0
click==8.1.3
click-help-colors==0.9.1
cookiecutter==2.1.1
cryptography==40.0.2
cryptography==41.0.0
enrich==1.2.7
idna==3.4
jinja2==3.1.2
Expand All @@ -33,7 +33,7 @@ pyrsistent==0.19.3
python-dateutil==2.8.2
python-slugify==8.0.1
pyyaml==6.0
requests==2.28.2
requests==2.31.0
resolvelib==0.8.1
rich==13.3.4
six==1.16.0
Expand Down
2 changes: 1 addition & 1 deletion .config/requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ansible-compat >= 2.2.0, < 4.0.0
ansible-compat >= 4.1.2
ansible-core >= 2.12.10
click >= 8.0, < 9
click-help-colors >= 0.9
Expand Down
2 changes: 1 addition & 1 deletion .config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# pip-compile --extra=docs --extra=test --no-annotate --output-file=.config/requirements.txt --resolver=backtracking --strip-extras pyproject.toml
#
ansi2html==1.8.0
ansible-compat==3.0.2
ansible-compat==4.1.2
ansible-core==2.14.4
ansible-lint==6.14.6
arrow==1.2.3
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ repos:
entry: mypy src/
pass_filenames: false
additional_dependencies:
- ansible-compat>=2.2.0,<4.0.0
- ansible-compat>=4.1.2
- click>=8.0.1
- enrich>=1.2.7
- importlib-metadata>=4.6.1
Expand All @@ -81,7 +81,7 @@ repos:
args:
- --output-format=colorized
additional_dependencies:
- ansible-compat>=2.2.0,<4.0.0
- ansible-compat>=4.1.2
- click
- click-help-colors
- cookiecutter
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ familiar with the basics of how to use Molecule and what it can offer.
In order to complete this guide by hand, you will need to additionally
install [Docker](https://docs.docker.com/). Molecule requires an
external Python dependency for the Docker driver which is provided when
installing Molecule using `pip install 'molecule[docker]'`.
installing Molecule using `pip install 'molecule-plugins[docker]'`.

## Creating a new role

Expand Down
15 changes: 13 additions & 2 deletions src/molecule/command/init/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def execute(self, action_args=None):

if namespace:
# we need to inject namespace info into meta/main.yml
cmd = [
cmd_meta = [
"ansible",
"localhost",
"-o", # one line output
Expand All @@ -99,7 +99,18 @@ def execute(self, action_args=None):
"-a",
f'path={role_name}/meta/main.yml line=" namespace: {namespace}" insertafter=" author: your name"',
]
util.run_command(cmd, check=True)
util.run_command(cmd_meta, check=True)
# we need to inject namespace info into tests/test.yml
cmd_tests = [
"ansible",
"localhost",
"-o", # one line output
"-m",
"lineinfile",
"-a",
f'path={role_name}/tests/test.yml line=" - {namespace}.{role_name}" regex="^(.*) - {role_name}"',
]
util.run_command(cmd_tests, check=True)

scenario_base_directory = os.path.join(role_directory, role_name)
templates = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

# TODO: Developer must implement and populate 'server' variable

- when: server.changed | default(false) | bool
- name: Create instance config
when: server.changed | default(false) | bool # noqa no-handler
block:
- name: Populate instance config dict
- name: Populate instance config dict # noqa jinja
ansible.builtin.set_fact:
instance_conf_dict: {
'instance': "{{ }}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
{{ instance_conf | to_json | from_json | to_yaml }}
dest: "{{ molecule_instance_config }}"
mode: 0600
when: server.changed | default(false) | bool
when: server.changed | default(false) | bool # noqa no-handler
{%- endraw %}
14 changes: 7 additions & 7 deletions src/molecule/test/functional/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
# ansible-lint config for functional testing, used to bypass expected metadata
# errors in molecule-generated roles. Loaded via the metadata_lint_update
# pytest helper. For reference, see "E7xx - metadata" in:
# https://docs.ansible.com/ansible-lint/rules/default_rules.html

# https://docs.ansible.com/ansible-lint/rules/default_rules.html

skip_list:
# metadata/201 - Trailing whitespace
- '201'
# metadata/701 - Role info should contain platforms
- '701'
# metadata/703 - Should change default metadata: <field>"
- '703'
- meta-incorrect
- schema[meta]
- name[play]
# See https://github.com/ansible/ansible/issues/63734
3 changes: 2 additions & 1 deletion src/molecule/test/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def metadata_lint_update(role_directory: str) -> None:
# the customize ansible-lint config is used.
with change_dir_to(role_directory):
cmd = ["ansible-lint", "."]
assert run_command(cmd).returncode == 0
result = run_command(cmd)
assert result.returncode == 0


def list_cmd(x):
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def run_command(
if debug:
print_environment_vars(env)

result = app.runtime.exec(
result = app.runtime.run(
args=args,
env=env,
cwd=cwd,
Expand Down

0 comments on commit dd0ab36

Please sign in to comment.