Actualizar 'playbooks/create_user_ssh/main.yml'
This commit is contained in:
parent
60b7f6cbed
commit
b349ec77e9
|
@ -1,40 +1,14 @@
|
||||||
---
|
---
|
||||||
- name: Add user | Debian based OS
|
- name: Install WordPress, MySQL, Nginx, and PHP-FPM
|
||||||
user:
|
hosts: all
|
||||||
name: "{{ username }}"
|
remote_user: root
|
||||||
groups: sudo,shadow
|
# remote_user: user
|
||||||
shell: /bin/bash
|
# become: yes
|
||||||
append: yes
|
# become_method: sudo
|
||||||
generate_ssh_key: yes
|
|
||||||
ssh_key_bits: 4096
|
|
||||||
ssh_key_file: .ssh/id_rsa
|
|
||||||
when: ansible_os_family == "Debian"
|
|
||||||
|
|
||||||
- name: Add user | Redhat based OS
|
roles:
|
||||||
user:
|
- common
|
||||||
name: "{{ username }}"
|
- mysql
|
||||||
groups: wheel
|
- nginx
|
||||||
shell: /bin/bash
|
- php-fpm
|
||||||
append: yes
|
- wordpress
|
||||||
generate_ssh_key: yes
|
|
||||||
ssh_key_bits: 4096
|
|
||||||
ssh_key_file: .ssh/id_rsa
|
|
||||||
when: ansible_os_family == "RedHat"
|
|
||||||
|
|
||||||
- name: Sudo | add to sudoers file and validate
|
|
||||||
lineinfile:
|
|
||||||
dest: /etc/sudoers
|
|
||||||
state: present
|
|
||||||
regexp: '^{{ username }} '
|
|
||||||
# line: '{{username}} ALL=(ALL) NOPASSWD:ALL'
|
|
||||||
line: "{{ username }} ALL=(ALL) {{ 'NOPASSWD:' if ( default_sudo_nopass|d(true)|bool ) else '' }}ALL"
|
|
||||||
validate: 'visudo -cf %s'
|
|
||||||
environment:
|
|
||||||
PATH: /usr/sbin:/usr/local/sbin:/sbin
|
|
||||||
#environment fixes Redhat issue of hard-coded path to visudo
|
|
||||||
|
|
||||||
- name: SSH Keys | Add authorized key for ssh key authentication
|
|
||||||
authorized_key:
|
|
||||||
user: "{{ username }}"
|
|
||||||
state: present
|
|
||||||
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
|
|
||||||
|
|
Loading…
Reference in New Issue