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

Add roles option to roles role to allow setting multiple roles in one item #658

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

Tompage1994
Copy link
Collaborator

What does this PR do?

Add roles option to roles role to allow setting multiple roles in one item rather than repeating entire sections of code

How should this be tested?

Added a new automated test

Is there a relevant Issue open for this?

resolves #606

Other Relevant info, PRs, etc

N/A

Copy link
Collaborator

@djdanielsson djdanielsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great improvement

Copy link
Contributor

@ivarmu ivarmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

… item rather than repeating entire sections of code
@djdanielsson djdanielsson merged commit 4f273f4 into redhat-cop:devel Aug 1, 2023
21 checks passed
Copy link
Contributor

@ivarmu ivarmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can reduce code/task duplication with the following idea:

---
- hosts: localhost
  connection: local
  gather_facts: false
  vars:
    - data:
        - name: row1
          roles:
            - role1
            - role2
        - name: row2
          role: roleA
  tasks:
    - debug:
        msg:
          - "{{ item.1 if item.1 is defined else item.role }}"
      loop: "{{ (data | selectattr('role', 'defined')) + (data | subelements(['roles'], skip_missing=true)) }}"
...

@ivarmu
Copy link
Contributor

ivarmu commented Aug 1, 2023

Yeah, I'm late... I was thinking about this... what do you think?

@Tompage1994
Copy link
Collaborator Author

Yeah, I'm late... I was thinking about this... what do you think?

Yes, that makes sense and it should work. I'll look at implementing another change here

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

Successfully merging this pull request may close these issues.

Roles controller support for multiple role per assignment
3 participants