vn-ansible/roles/config-awx-user/tasks/main.yaml

46 lines
1.5 KiB
YAML
Raw Normal View History

2023-10-11 11:45:13 +00:00
---
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-11 11:45:13 +00:00
# create user awx-user on debian os
- name: Create a ssh user awx-user in the system
user:
name: awx-user
password: '*'
shell: /bin/bash
groups: sudo
state: present
comment: ssh user
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-11 11:45:13 +00:00
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-11 11:45:13 +00:00
# add ssh-key pub to user awx-user
- name: Adding ssh-pub-key to user awx-user
authorized_key:
user: awx-user
key: "{{ key_to_add }}"
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-11 11:45:13 +00:00
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# install sudo package
- name: Install sudo package
apt:
name: sudo
state: present
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-11 11:45:13 +00:00
# add awx-user to sudoers
- name: Add awx-user to sudoers
file:
path: /etc/sudoers.d/awx-user
state: touch
mode: u=rw,g=r,o=r
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# add a line to /etc/sudoers.d/awx-user file
- name: add a line to /etc/sudoers.d/awx-user file
lineinfile:
path: /etc/sudoers.d/awx-user
line: awx-user ALL=(ALL) NOPASSWD:ALL
2023-10-18 07:09:20 +00:00
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++