testnet-ops/service-provider-setup/setup-user.yml
nabarun 18df60a291 Add ansible playbook to automate service provider setup (#10)
Part of [Service Provider setup](https://www.notion.so/Service-provider-setup-a09e2207e1f34f3a847f7ce9713b7ac5)
- Added ansible playbooks for:
  - Adding a new user with passwordless sudo
  - Configuring DNS records
  - Setting up the system with required packages and gpg key
  - Deploying k8s
  - Setting up container registry
  - Setting up laconicd and laconic-console
  - Setting up and starting webapp-deployer-api and webapp-deployer-ui
- TODOs:
  - Mount gpg keys in webapp-deployer-api container

Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Reviewed-on: #10
2024-10-01 12:17:10 +00:00

47 lines
1.2 KiB
YAML

- name: Configure system
hosts: root_host
become: yes
vars_files:
- vars/user-vars.yml
tasks:
- name: Create a user
user:
name: "{{ username }}"
password: "{{ '{{ password }}' | password_hash('sha512') }}"
shell: /bin/bash
state: present
- name: Add user to sudoers group
user:
name: "{{ username }}"
groups: sudo
append: yes
- name: Ensure .ssh directory exists for user
file:
path: /home/{{ username }}/.ssh
state: directory
owner: "{{ username }}"
group: "{{ username }}"
mode: '0700'
- name: Append SSH public key to authorized_keys
lineinfile:
path: /home/{{ username }}/.ssh/authorized_keys
line: "{{ lookup('file', path_to_ssh_key) }}"
create: yes
owner: "{{ username }}"
group: "{{ username }}"
mode: '0600'
state: present
- name: Add user to sudoers for passwordless sudo
lineinfile:
path: /etc/sudoers
state: present
regexp: '^{{ username }} ALL=\(ALL\) NOPASSWD:ALL'
line: '{{ username }} ALL=(ALL) NOPASSWD:ALL'
validate: 'visudo -cf %s'