Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use backwards incompatible change from ansible-compat 4.0.1 #3904

Merged
merged 7 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .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 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
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