You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1021 B
44 lines
1021 B
4 years ago
|
---
|
||
|
- hosts: service
|
||
|
remote_user: "{{ user }}"
|
||
|
gather_facts: no
|
||
|
vars:
|
||
|
user: "zeus"
|
||
|
|
||
|
|
||
|
tasks:
|
||
|
|
||
|
- name: Create a login user
|
||
|
become: true
|
||
|
user:
|
||
|
name: "{{ ruser }}"
|
||
|
password: "{{ rpassword }}"
|
||
|
groups: # Empty by default, here we give it some groups
|
||
|
- sudo
|
||
|
state: present
|
||
|
shell: /bin/bash # Defaults to /bin/bash
|
||
|
system: no # Defaults to no
|
||
|
createhome: yes # Defaults to yes
|
||
|
home: "/home/{{ ruser }}" # Defaults to /home/<username>
|
||
|
|
||
|
- name: Creates directory .ssh
|
||
|
become: true
|
||
|
file:
|
||
|
path: "/home/{{ ruser }}/.ssh"
|
||
|
state: directory
|
||
|
owner: "{{ ruser }}"
|
||
|
group: "{{ ruser }}"
|
||
|
mode: 0700
|
||
|
recurse: yes
|
||
|
|
||
|
- name: copy auth file authorized_keys
|
||
|
become: true
|
||
|
copy:
|
||
|
src: ../files/authorized_keys
|
||
|
dest: "/home/{{ ruser }}/.ssh/authorized_keys"
|
||
|
owner: "{{ ruser }}"
|
||
|
group: "{{ ruser }}"
|
||
|
mode: 0644
|
||
|
|
||
|
|