J. *_*Doe 1 ansible ansible-playbook
我有一个输出哈希值的python脚本。我希望将该哈希通过管道传递到ansible脚本中的变量中。
Python命令看起来像这样-
#!/bin/python
import crypt
test= crypt.crypt('test', '$6$Som3S@lt$')
print test
Run Code Online (Sandbox Code Playgroud)
我的ansible剧本看起来像这样-
hosts: webservers
remote_user: test
become: yes
become_method: sudo
vars:
pass:
tasks:
- name: Run Python Password script
command: /home/test/userPW.py > pass
Run Code Online (Sandbox Code Playgroud)
谢谢
尝试注册。
? ~ cat test.yml
---
- hosts: 127.0.0.1
user: jenkins
connection: local
tasks:
- name: password
shell: cat /tmp/pass
register: pass
- debug: var=pass.stdout
? ~ ansible-playbook -i hosts test.yml
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [127.0.0.1]
TASK [password] ****************************************************************
changed: [127.0.0.1]
TASK [debug] *******************************************************************
ok: [127.0.0.1] => {
"pass.stdout": "mypassword"
}
PLAY RECAP *********************************************************************
127.0.0.1 : ok=3 changed=1 unreachable=0 failed=0
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3006 次 |
最近记录: |