community.general.consul_session 模块 – 操作 Consul 会话
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了这个集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。
要在 playbook 中使用它,请指定:community.general.consul_session
。
概要
允许在 Consul 集群中添加、修改和删除会话。这些会话随后可以与键值对结合使用,以实现分布式锁。有关使用会话的深入文档,请访问 http://www.consul.io/docs/internals/sessions.html
参数
参数 |
注释 |
---|---|
创建会话时可以附加的可选行为。这控制会话失效时的行为。 选项
|
|
用于 https 连接的 CA 捆绑包 |
|
用于验证会话运行状况的检查。如果所有检查都失败,则会话将失效,并且与该会话关联的任何锁都将被释放,并且可以在关联的锁延迟过期后获取。 |
|
会话存在或应该创建的数据中心的名称。 |
|
创建会话时可以附加的可选锁定延迟。失效会话的锁在延迟过期之前被阻止获取。持续时间以秒为单位。 默认值: |
|
Consul 代理的主机,默认为 默认值: |
|
会话的 ID,当 |
|
应与会话关联的名称。当使用 |
|
会话将与之关联的节点的名称。默认情况下,这是代理的名称。 |
|
Consul 代理正在运行的端口。 默认值: |
|
Consul 代理正在运行的协议方案。默认为 默认值: |
|
用于授权的令牌。 |
|
指定会话的持续时间(以秒为单位,介于 10 到 86400 之间)。 |
|
是否验证 consul 代理的 TLS 证书。 选项
|
属性
属性 |
支持 |
描述 |
---|---|---|
操作组: community.general.consul 在 community.general 8.3.0 中添加 |
在 |
|
支持: 无 |
可以在 |
|
支持: 无 |
在 diff 模式下,将返回已更改的内容的详细信息(或可能需要在 |
示例
- name: Register basic session with consul
community.general.consul_session:
name: session1
- name: Register a session with an existing check
community.general.consul_session:
name: session_with_check
checks:
- existing_check_name
- name: Register a session with lock_delay
community.general.consul_session:
name: session_with_delay
delay: 20s
- name: Retrieve info about session by id
community.general.consul_session:
id: session_id
state: info
- name: Retrieve active sessions
community.general.consul_session:
state: list
- name: Register session with a ttl
community.general.consul_session:
name: session-with-ttl
ttl: 600 # sec