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

Rundeck is not able to use Variables defined in inventory file #304

Open
Befrog57 opened this issue Oct 14, 2021 · 1 comment
Open

Rundeck is not able to use Variables defined in inventory file #304

Befrog57 opened this issue Oct 14, 2021 · 1 comment

Comments

@Befrog57
Copy link

There seems to be a Problem with variables that are defined in the invertory file.
Example hosts.yml:

all:
  hosts:
  children:
    production:
      vars:
        ansible_python_interpreter: /usr/bin/python3
      hosts:
        host1.com:
          userlist:
            - user_name: "user1"
        host2.com:
          userlist:
            - user_name: "user1"
            - user_name: "user2"
            - user_name: "user3"
        host3.com:
          userlist:
            - user_name: "user1"

Example paybook that uses theese vars:

---
- hosts: all
  remote_user: root
  tasks:
    - name: Add users
      ansible.builtin.user:
        name: "{{ item.user_name }}"
        shell: /bin/bash
        groups: wheel
        append: yes
      with_items: "{{ userlist }}"

    - name: Set authorized key {{ item.user_name }}
      authorized_key:
        user: "{{ item.user_name }}"
        state: present
        key: "{{ lookup('file', '../files/ssh-keys/{{ item.user_name }}.pub') }}"
      with_items: "{{ userlist }}"

When executed on CLI it works just fine.

When executed in Rundeck this error message appears:

The task includes an option with an undefined variable. The error was: 'user_name' is undefined
@rezizter
Copy link

rezizter commented Jun 5, 2023

I have the same issue. Perhaps any resolution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants