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

rework some of ansible's inner templating #72419

Draft
wants to merge 13 commits into
base: devel
Choose a base branch
from

Conversation

bcoca
Copy link
Member

@bcoca bcoca commented Oct 30, 2020

  • vars is now a template object that is autosolvable
    also 'fixes' vars['varname'] not being templated.
  • avoid full vars dict copy now for every get_vars call.
  • moved to use common object for hostvarsvars as for vars.

related #72829

ISSUE TYPE
  • Bugfix Pull Request
  • Feature Pull Request
COMPONENT NAME

vars

@ansibot ansibot added affects_2.11 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 30, 2020
@ansibot

This comment has been minimized.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. and removed core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Oct 30, 2020
@ansibot

This comment has been minimized.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. test This PR relates to tests. and removed core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Oct 30, 2020
@ansibot

This comment has been minimized.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Oct 30, 2020
@samdoran samdoran added the ci_verified Changes made in this PR are causing tests to fail. label Oct 31, 2020
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:community This issue/PR relates to code supported by the Ansible community. and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. core_review In order to be merged, this PR must follow the core review workflow. labels Nov 2, 2020
@bcoca bcoca force-pushed the template_uninsanity branch from cff8d23 to 6f2f190 Compare November 3, 2020 17:00
@ansibot ansibot removed the core_review In order to be merged, this PR must follow the core review workflow. label Nov 3, 2020
@ansibot
Copy link
Contributor

ansibot commented Oct 15, 2021

The test ansible-test sanity --test package-data [explain] failed with the error:

Command "/root/.ansible/test/venv/sanity.package-data/3.10/431ccf3c/bin/python /root/ansible/test/sanity/code-smell/package-data.py" returned exit status 1.
>>> Standard Error
Traceback (most recent call last):
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 383, in <module>
    main()
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 360, in main
    sdist_path = create_sdist(tmp_dir)
  File "/root/ansible/test/sanity/code-smell/package-data.py", line 174, in create_sdist
    raise Exception('make snapshot failed:\n%s' % stderr)
Exception: make snapshot failed:
Traceback (most recent call last):
  File "/tmp/tmpu7mad4ph/hacking/build-ansible.py", line 103, in <module>
    main()
  File "/tmp/tmpu7mad4ph/hacking/build-ansible.py", line 92, in main
    retval = command.main(args)
  File "/tmp/tmpu7mad4ph/hacking/build_library/build_ansible/command_plugins/generate_man.py", line 279, in main
    allvars[cli_name] = opts_docs(cli_class_name, cli_name)
  File "/tmp/tmpu7mad4ph/hacking/build_library/build_ansible/command_plugins/generate_man.py", line 119, in opts_docs
    cli_klass = getattr(__import__("ansible.cli.%s" % cli_module_name,
  File "/tmp/tmpu7mad4ph/lib/ansible/cli/config.py", line 25, in <module>
    from ansible.parsing.yaml.dumper import AnsibleDumper
  File "/tmp/tmpu7mad4ph/lib/ansible/parsing/yaml/dumper.py", line 30, in <module>
    from ansible.vars.hostvars import HostVars, HostVarsVars
ImportError: cannot import name 'HostVarsVars' from 'ansible.vars.hostvars' (/tmp/tmpu7mad4ph/lib/ansible/vars/hostvars.py)
make: *** [Makefile:190: generate_rst] Error 1

The test ansible-test sanity --test docs-build [explain] failed with the error:

Command "/root/.ansible/test/venv/sanity.docs-build/3.10/966adace/bin/python /root/ansible/test/sanity/code-smell/docs-build.py" returned exit status 1.
>>> Standard Error
Command 'make core_singlehtmldocs' failed with status code: 2
--> Standard Output
Creating symlinks in core_structure
ln -sf ../rst/core_index.rst rst/index.rst
ln -sf ../sphinx_conf/core_conf.py rst/conf.py
../../hacking/build-ansible.py collection-meta --template-file=../templates/collections_galaxy_meta.rst.j2 --output-dir=rst/dev_guide/  ../../lib/ansible/galaxy/data/collections_galaxy_meta.yml
../../hacking/build-ansible.py document-config --template-file=../templates/config.rst.j2 --output-dir=rst/reference_appendices/  ../../lib/ansible/config/base.yml
mkdir -p rst/cli
../../hacking/build-ansible.py generate-man --template-file=../templates/cli_rst.j2 --output-dir=rst/cli/ --output-format rst  ../../lib/ansible/cli/*.py
--> Standard Error
Traceback (most recent call last):
  File "/root/ansible/docs/docsite/../../hacking/build-ansible.py", line 103, in <module>
    main()
  File "/root/ansible/docs/docsite/../../hacking/build-ansible.py", line 92, in main
    retval = command.main(args)
  File "/root/ansible/hacking/build_library/build_ansible/command_plugins/generate_man.py", line 279, in main
    allvars[cli_name] = opts_docs(cli_class_name, cli_name)
  File "/root/ansible/hacking/build_library/build_ansible/command_plugins/generate_man.py", line 119, in opts_docs
    cli_klass = getattr(__import__("ansible.cli.%s" % cli_module_name,
  File "/root/ansible/lib/ansible/cli/config.py", line 25, in <module>
    from ansible.parsing.yaml.dumper import AnsibleDumper
  File "/root/ansible/lib/ansible/parsing/yaml/dumper.py", line 30, in <module>
    from ansible.vars.hostvars import HostVars, HostVarsVars
ImportError: cannot import name 'HostVarsVars' from 'ansible.vars.hostvars' (/root/ansible/lib/ansible/vars/hostvars.py)
make: *** [Makefile:192: cli] Error 1

The test ansible-test sanity --test ansible-doc [explain] failed with the error:

Command "ansible-doc -t become runas su sudo" returned exit status 250.
>>> Standard Error
ERROR! Unexpected Exception, this is probably a bug: cannot import name 'HostVarsVars' from 'ansible.vars.hostvars' (/root/ansible/lib/ansible/vars/hostvars.py)

The test ansible-test sanity --test import --python 3.9 [explain] failed with 1 error:

lib/ansible/plugins/filter/core.py:34:0: traceback: ImportError: cannot import name 'HostVarsVars' from 'ansible.vars.hostvars' (/root/ansible/lib/ansible/vars/hostvars.py) (at lib/ansible/parsing/yaml/dumper.py:30:0)

The test ansible-test sanity --test import --python 3.8 [explain] failed with 1 error:

lib/ansible/plugins/filter/core.py:34:0: traceback: ImportError: cannot import name 'HostVarsVars' from 'ansible.vars.hostvars' (/root/ansible/lib/ansible/vars/hostvars.py) (at lib/ansible/parsing/yaml/dumper.py:30:0)

The test ansible-test sanity --test import --python 3.10 [explain] failed with 1 error:

lib/ansible/plugins/filter/core.py:34:0: traceback: ImportError: cannot import name 'HostVarsVars' from 'ansible.vars.hostvars' (/root/ansible/lib/ansible/vars/hostvars.py) (at lib/ansible/parsing/yaml/dumper.py:30:0)

The test ansible-test sanity --test pylint [explain] failed with 1 error:

test/sanity/ignore.txt:131:1: ansible-test: Ignoring 'disallowed-name' on 'lib/ansible/vars/hostvars.py' is unnecessary

click here for bot help

@ansibot ansibot removed the pre_azp This PR was last tested before migration to Azure Pipelines. label Oct 15, 2021
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 23, 2021
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Mar 2, 2022
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed has_issue labels Jul 12, 2023
bcoca added 13 commits August 7, 2023 11:21
  - vars is now a template object that is autosolvable
    also 'fixes' vars['varname'] not being templated.
  - avoid full vars dict copy now for every get_vars call.
  - moved to use common object for hostvarsvars as for vars.
 also added comment to autovars init
@bcoca bcoca force-pushed the template_uninsanity branch from b21d8e9 to c3bd068 Compare August 7, 2023 15:26
@ansibot ansibot removed the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Aug 7, 2023
@webknjaz webknjaz added the ci_verified Changes made in this PR are causing tests to fail. label Aug 7, 2023
@ansibot ansibot removed ci_verified Changes made in this PR are causing tests to fail. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Aug 7, 2023
@ansibot
Copy link
Contributor

ansibot commented Aug 7, 2023

The test ansible-test sanity --test pylint [explain] failed with 3 errors:

lib/ansible/parsing/yaml/dumper.py:30:0: unused-import: Unused HostVarsVars imported from ansible.vars.hostvars
lib/ansible/vars/hostvars.py:147:86: undefined-variable: Undefined variable 'STATIC_VARS'
lib/ansible/vars/hostvars.py:161:86: undefined-variable: Undefined variable 'STATIC_VARS'

click here for bot help

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Aug 21, 2023
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Apr 2, 2024
@ansibot ansibot added the stale_pr This PR has not been pushed to for more than one year. label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.11 bug This issue/PR relates to a bug. feature This issue/PR relates to a feature request. needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_pr This PR has not been pushed to for more than one year. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants