community.general.consul_policy module – Manipulate Consul policies
Note
This module is part of the community.general collection (version 7.5.2).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.general
.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.consul_policy
.
New in community.general 7.2.0
Synopsis
Allows the addition, modification and deletion of policies in a consul cluster via the agent. For more details on using and configuring ACLs, see https://www.consul.io/docs/guides/acl.html.
Requirements
The below requirements are needed on the host that executes this module.
requests
Parameters
Parameter |
Comments |
---|---|
Description of the policy. Default: |
|
Host of the consul agent, defaults to localhost. Default: |
|
The name that should be associated with the policy, this is opaque to Consul. |
|
The port on which the consul agent is running. Default: |
|
Rule document that should be associated with the current policy. |
|
The protocol scheme on which the consul agent is running. Default: |
|
Whether the policy should be present or absent. Choices:
|
|
A management token is required to manipulate the policies. |
|
Valid datacenters for the policy. All if list is empty. Default: |
|
Whether to verify the TLS certificate of the consul agent or not. Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Examples
- name: Create a policy with rules
community.general.consul_policy:
host: consul1.example.com
token: some_management_acl
name: foo-access
rules: |
key "foo" {
policy = "read"
}
key "private/foo" {
policy = "deny"
}
- name: Update the rules associated to a policy
community.general.consul_policy:
host: consul1.example.com
token: some_management_acl
name: foo-access
rules: |
key "foo" {
policy = "read"
}
key "private/foo" {
policy = "deny"
}
event "bbq" {
policy = "write"
}
- name: Remove a policy
community.general.consul_policy:
host: consul1.example.com
token: some_management_acl
name: foo-access
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The operation performed on the policy. Returned: changed Sample: |