我已经在Windows服务器上安装了Elasticsearch与ansible的AWX。现在我试图重置初始密码为我的新密码(与ansible以及)。
我知道我可以手动执行此操作:
D:\elasticsearch-8.6.0\bin\elasticsearch-reset-password -b -u elastic -i
但是我找不到通过ansible来做/读它的方法。
我也可以发送API请求与ansible:
- name: Push password
ansible.windows.win_uri:
url: http://localhost:9200/_security/user/_password?pretty
method: PUT
url_username: elastic
url_password: my_password
body:
password: my_new_password
headers:
Content-Type: "application/json"
但它要求我提供旧密码,而在手动重置之前我并不知道(这是我试图自动化的)。
有没有办法用ansible做到这一点?
1条答案
按热度按时间6g8kf2rb1#
最有效的方法是将密码直接重置为目标密码,但是由于您只能使用
elasticsearch-reset-password
交互地执行此操作,因此这需要使用ansible.builtin.expect
module,不幸的是available only for linux hosts所以在Windows下,我恐怕唯一的选择就是:
1.重置为随机密码并将其读入变量
1.将随机密码更改为要配置的密码
发出以下命令:
在
stdout
上输出如下内容:所以我们要找的信息在最后一行
考虑到这一点,下面的(未经测试的)剧本应该会达到你的期望(或者至少让你走上正轨)。