exam 15
- 01
- 02
- 03
- 04
Write a playbook: ~/playbooks/add_user_with_ssh.yml
to create a user: deploy
on remote hosts. Its a best practice to ssh using public-key than to use a plain text password. Copy the public key: ~/playbooks/devops.pub
to remote hosts inside deploy user's authorized_keys.
Use inventory file: ~/playbooks/inventory
.
Create add_user_with_ssh.yml
playbook and add below given code
---
- hosts: all
tasks:
- user:
name: deploy
state: present
- authorized_key:
user: deploy
key: "{{ lookup('file', 'devops.pub') }}"
state: present
Comments
Post a Comment