forked from cerc-io/testnet-ops
nabarun
65be098ce9
Part of [Service Provider Setup](https://www.notion.so/Service-provider-setup-a09e2207e1f34f3a847f7ce9713b7ac5) - Move user setup playbook to separate directory - Remove unneeded variables Co-authored-by: Adw8 <adwaitgharpure@gmail.com> Reviewed-on: cerc-io/testnet-ops#14
75 lines
1.7 KiB
Markdown
75 lines
1.7 KiB
Markdown
# user-setup
|
|
|
|
## Prerequisites
|
|
|
|
- Setup Ansible: follow the [installation](../README.md#installation) guide to setup ansible on your machine.
|
|
|
|
- Setup a remote machine with passwordless SSH login for the root user
|
|
|
|
- Install `passlib` used for handling encrypted passwords when setting up a user
|
|
|
|
```bash
|
|
pip install passlib
|
|
```
|
|
|
|
## Setup a user
|
|
|
|
- Create a new `hosts.ini` file:
|
|
|
|
```bash
|
|
cd user-setup/
|
|
cp ../hosts.example.ini hosts.ini
|
|
```
|
|
|
|
- Edit the [`hosts.ini`](./hosts.ini) file:
|
|
|
|
```ini
|
|
[deployment_host]
|
|
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
|
|
```
|
|
|
|
- Replace `<host_name>` with the desired `hostname` of the remote machine
|
|
- Replace `<target_ip>` with the IP address or hostname of the target machine
|
|
- Replace `<ssh_user>` with `root`
|
|
|
|
- Verify that you are able to connect to the host using the following command:
|
|
|
|
```bash
|
|
ansible all -m ping -i hosts.ini
|
|
|
|
# Expected output:
|
|
|
|
# <host_name> | SUCCESS => {
|
|
# "ansible_facts": {
|
|
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
|
# },
|
|
# "changed": false,
|
|
# "ping": "pong"
|
|
# }
|
|
```
|
|
|
|
- Setup `user-vars.yml` using the example file
|
|
|
|
```bash
|
|
cp user-vars.example.yml user-vars.yml
|
|
```
|
|
|
|
- Edit the `user-vars.yml` file:
|
|
|
|
```bash
|
|
# name of the user you want to setup on the target host
|
|
username: ""
|
|
|
|
# password of the user you want to setup on the target host
|
|
password: ""
|
|
|
|
# path to the ssh key on your machine, eg: "/home/user/.ssh/id_rsa.pub"
|
|
path_to_ssh_key: ""
|
|
```
|
|
|
|
- Execute the `setup-user.yml` Ansible playbook to create a user with passwordless sudo permissions:
|
|
|
|
```bash
|
|
LANG=en_US.utf8 ansible-playbook setup-user.yml -i hosts.ini
|
|
```
|