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

fix Rules attribute formatting to allow for proper creation #8

Merged
merged 2 commits into from
Feb 15, 2024

Conversation

nicholasmhughes
Copy link
Member

What does this PR do?

Port saltstack/salt#62598 to this extension.

What issues does this PR fix or reference?

Fixes: #7

Previous Behavior

If Rules attribute was provided, the rules text added was incorrectly formatted

New Behavior

Consul ACL rules are correctly created. If we show the rules with acl_list: For example, having a state that takes the rules as a list:

consul.acl_create_agent_token.{{ host }}:
  my_utils.acl_create:
    - name: {{ policy }}
    - consul_url: {{ consul.url }}
    - token: {{ secrets.mgmt_token }}
    - rules:
      - node: "{{ host + '.' + grains.domain }}"
        policy: "write"
      - agent: "{{ host + '.' + grains.domain }}"
        policy: "write"
      - session: "{{ host + '.' + grains.domain }}"
        policy: "write"
      - key: ""
        policy: "read"
      - service: ""
        policy: "read"

Then to check:

salt `hostname` consul.acl_list

          CreateIndex:                                                                                                                                                             
              81
          ID:
              e3d6e184-660a-381f-d2fe-d6978395b057
          ModifyIndex:
              82
          Name:
              host agent token
          Rules:
              node "host" {
                policy = "write"
              }
              service "" {
                policy = "read"
              }
              agent "host" {
                policy = "write"
              }
              session "host" {
                policy = "write"
              }
              key "" {
                policy = "read"
              }
          Type:
              client 

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@nicholasmhughes
Copy link
Member Author

@cesan3, can you take a look and ensure this port of your PR is correct?

@cesan3
Copy link

cesan3 commented Jan 13, 2024

@cesan3, can you take a look and ensure this port of your PR is correct?

Looks good. Thx @nicholasmhughes

@KYTG-Dev
Copy link

suggestion (non-blocking): Adding a bit more detail to the docstrings regarding the decode and text parameters could enhance clarity around those params

@nicholasmhughes nicholasmhughes merged commit 38ff316 into salt-extensions:main Feb 15, 2024
17 checks passed
@nicholasmhughes nicholasmhughes deleted the port-pr-62598 branch February 15, 2024 21:44
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.

[BUG] consul.acl_create rule creation doesn't work preoperly
3 participants