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

Passing variable in extra_vars not working #770

Closed
jschilen opened this issue Feb 13, 2024 · 2 comments
Closed

Passing variable in extra_vars not working #770

jschilen opened this issue Feb 13, 2024 · 2 comments
Labels
bug Something isn't working new New issue, this should be removed once reviewed

Comments

@jschilen
Copy link

Summary

Trying to use the following in a controller_job_templates.d file:
extra_vars:
host_domain: some.domain
ansible_host: '"{{ inventory_hostname_short }}.{{ host_domain }}"'

When the apply_template job runs in AWX it errors with:
ERROR! Unexpected Exception, this is probably a bug: unsupported operand type(s) for |=: 'bool' and 'str'

Issue Type

  • Bug Report

Ansible, Collection, Controller details

ansible --version
ansible [core 2.14.13]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/[redacted]/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.9/site-packages/ansible
  ansible collection location = /home/[redacted]/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.9.18 (main, Jan  4 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

ansible-galaxy collection list

Controller version
 AWX 23.7.0

Desired Behavior

I want the resulting job template in the AWX gui to have these variables:

host_domain: some.domain
ansible_host: "{{inventory_hostname_short}}.{{host_domain}}"

Actual Behavior

Giving an error instead of completing.

failed: [localhost] (item={'path': 'orgs_vars/Default/env/common/controller_job_templates.d/TEMPLATE-ADjoin-Windows.yml', 'mode': '0644', 'isdir': False, 'ischr': False, 'isblk': False, 'isreg': True, 'isfifo': False, 'islnk': False, 'issock': False, 'uid': 1000, 'gid': 0, 'size': 585, 'inode': 12411441, 'dev': 1048671, 'nlink': 1, 'atime': 1707843742.0, 'mtime': 1707843742.0, 'ctime': 1707843772.909364, 'gr_name': 'root', 'pw_name': '1000', 'wusr': True, 'rusr': True, 'xusr': False, 'wgrp': False, 'rgrp': True, 'xgrp': False, 'woth': False, 'roth': True, 'xoth': False, 'isuid': False, 'isgid': False}) => {"__read_job_templates_definitions_item": {"atime": 1707843742.0, "ctime": 1707843772.909364, "dev": 1048671, "gid": 0, "gr_name": "root", "inode": 12411441, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "mode": "0644", "mtime": 1707843742.0, "nlink": 1, "path": "orgs_vars/Default/env/common/controller_…
ERROR! Unexpected Exception, this is probably a bug: unsupported operand type(s) for |=: 'bool' and 'str'

STEPS TO REPRODUCE

In file orgs_vars\Default\env\common\controller_job_templates.d\TEMPLATE-ADjoin-Windows.yml

---
controller_templates:
  - name: TEMPLATE / AD Join-Windows
    job_type: run
    inventory: someinventory
    execution_environment: CustomExecutionEnvironment
    project: someproject
    playbook: playbooks/ad_join_windows.yml
    description: awx-build created AD join 
    extra_vars:
      host_domain: some.domain
      ansible_host: '"{{ inventory_hostname_short }}.{{ host_domain }}"'
    credentials:
    - administrator
@jschilen jschilen added bug Something isn't working new New issue, this should be removed once reviewed labels Feb 13, 2024
@djdanielsson
Copy link
Collaborator

It is trying to calculate the variables not have it come across as variables which I think is what you are looking for, see the !unsafe like we suggest in those cases like cred type

@jschilen
Copy link
Author

Thank you that was in fact what I needed. I've never seen that before. Greatly appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new New issue, this should be removed once reviewed
Projects
None yet
Development

No branches or pull requests

2 participants