【问题标题】:Using Encrypted Ansible Password in Python Script在 Python 脚本中使用加密的 Ansible 密码
【发布时间】:2022-01-14 16:41:26
【问题描述】:

我正在使用 Ansible 运行带有参数的 python 脚本。其中一个参数是用户密码

script: "{{ path_to_setup_py }} --username {{ username }} --password {{ password }} --ip {{ ip }} --hostname {{ hostname }}"

这可以提取除密码之外的所有内容,密码是用户输入,然后被加密。

name: password
prompt: Enter your password
private: yes
encrypt: sha512_crypt
confirm: yes
salt_size: 7

运行 python 脚本时,密码作为哈希值出现,不使用实际密码。我怎样才能得到它来解密哈希然后在脚本上运行它?

任何帮助将不胜感激,我是初学者。

【问题讨论】:

    标签: python ansible


    【解决方案1】:

    作为the fine manual says,使用encrypt: 确实是一种专门化,当您只想将该值发送到user: 模块中,而不与它进一步交互。

    如果您只是想让密码不回显到屏幕上,那就是 private: yes 控制的内容

    简而言之,除非您有未在问题中披露的要求,否则解决方案是删除 encrypt:salt_size: 参数:

      name: password
      prompt: Enter your password
      private: yes
      confirm: yes
    

    【讨论】:

      猜你喜欢
      • 2018-07-20
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      • 2020-08-11
      • 2021-04-20
      相关资源
      最近更新 更多