diff --git a/README.md b/README.md index 64a60d7..91572e3 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,18 @@ - Reference: +- Install `sshpass` used for automating SSH password authentication + + ```bash + sudo apt-get install sshpass + ``` + +- Install `passlib` used for handling encrypted passwords + + ```bash + pip install passlib + ``` + ## Playbooks - [stack-orchestrator-setup](./stack-orchestrator-setup/README.md) diff --git a/user-setup/.gitignore b/user-setup/.gitignore new file mode 100644 index 0000000..ab0c719 --- /dev/null +++ b/user-setup/.gitignore @@ -0,0 +1 @@ +user-vars.yml diff --git a/user-setup/README.md b/user-setup/README.md new file mode 100644 index 0000000..36cb980 --- /dev/null +++ b/user-setup/README.md @@ -0,0 +1,65 @@ +# user-setup + +## Setup Ansible + +To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine. + +## Setup a user + +- Create a new `hosts.ini` file: + + ```bash + cp ../hosts.example.ini hosts.ini + ``` + +- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine: + + ```ini + [deployment_host] + ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' + ``` + + - Replace `` with the desired `hostname` of the remote machine + - Replace `` with the IP address or hostname of the target machine + - Replace `` 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: + + # | 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 + ``` diff --git a/service-provider-setup/setup-user.yml b/user-setup/setup-user.yml similarity index 96% rename from service-provider-setup/setup-user.yml rename to user-setup/setup-user.yml index 35fca4c..d74d84f 100644 --- a/service-provider-setup/setup-user.yml +++ b/user-setup/setup-user.yml @@ -1,9 +1,9 @@ - name: Configure system - hosts: root_host + hosts: deployment_host become: yes vars_files: - - vars/user-vars.yml + - user-vars.yml tasks: - name: Create a user diff --git a/service-provider-setup/vars/user-vars.example.yml b/user-setup/user-vars.example.yml similarity index 100% rename from service-provider-setup/vars/user-vars.example.yml rename to user-setup/user-vars.example.yml