小编Nit*_*rma的帖子

如何在 ansible 角色中使用 vars

我想创建一个 ansible 角色来使用 ssh_keys 添加用户

\n\n
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ansible.cfg\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 hosts\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 playbooks\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 add_user.yml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 roles\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 add-user\n        \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 files\n        \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ansible.pub\n        \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 dhirendra.pub\n        \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 nitigyas.pub\n        \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 vinayaks.pub\n        \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tasks\n        \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n        \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 vars\n            \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n
Run Code Online (Sandbox Code Playgroud)\n\n

tasks/main.yml 文件是:

\n\n
---\n- name: AddUser in the server\n  user: \n   name: ansible\n   password: $6$sHQAZJ32E$ujHauabN7ZTbOQ/zhT5899EIaFErOecXYvTEyhekexy4dydsAXTGdUpaB8M4fQf2UGpZgX/Zg2Uv6areeuv/r0\n   comment: Ansible Configuration Mgmt\n   shell: /bin/bash\n\n- name: Add SSH key to users home direcotory\n  authorized_key: \n   user: "{{ item.name }}"\n   key: "{{ item.file }}"\n   state: present\n …
Run Code Online (Sandbox Code Playgroud)

ansible yaml

1
推荐指数
1
解决办法
4515
查看次数

标签 统计

ansible ×1

yaml ×1