From 1b50f0c5492d10685899ec1f4c7ce436584cb9cd Mon Sep 17 00:00:00 2001 From: Adw8 Date: Fri, 27 Sep 2024 16:26:43 +0530 Subject: [PATCH] Add separate entry in hosts file for setting up user --- service-provider-setup/README.md | 128 ++++++------------ service-provider-setup/deploy-backend.yml | 4 - service-provider-setup/deploy-frontend.yml | 4 - .../run-laconic-console.yml | 4 - service-provider-setup/run-laconicd.yml | 6 - .../setup-container-registry.yml | 4 - service-provider-setup/setup-k8s.yml | 4 - service-provider-setup/setup-system.yml | 4 - service-provider-setup/setup-user.yml | 2 +- 9 files changed, 42 insertions(+), 118 deletions(-) diff --git a/service-provider-setup/README.md b/service-provider-setup/README.md index c3050a5..0cde7d8 100644 --- a/service-provider-setup/README.md +++ b/service-provider-setup/README.md @@ -4,68 +4,6 @@ To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine -## Setup a new 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 - cd vars - cp user-vars.example.yml user-vars.yml - ``` - -- Edit the following vars: - - ```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 - path_to_ssh_key: " - ``` - -- Execute the `setup-user.yml` Ansible playbook to create a user with passwordless sudo permissions: - - ```bash - cd ../ - ansible-playbook setup-user.yml -i hosts.ini --extra-vars='{ "target_host": "deployment_host" }' - ``` - ## Become a Service Provider ### Prerequisites @@ -74,34 +12,11 @@ To get started, follow the [installation](../README.md#installation) guide to se - Generate a DigitalOcean access token -- Create a PGP key on your target host - - ``` - gpg --full-generate-key - ``` - -- List the secret keys - - ``` - gpg --list-secret-keys --keyid-format=long - ``` - -- This will output something like this - - ``` - [keyboxd] - --------- - sec rsa4096/0AFB10B643944C22 2024-05-03 [SC] [expires: 2025-05-03] - 17B3248D6784EC6CB43365A60AFB10B643944C22 - uid [ultimate] user - ``` - - Note the `0AFB10B643944C22` sequence of characters after `sec`. This will be required later. - - Copy the vars files: ```bash cd vars + cp user-vars.example.yml user-vars.yml cp dns-vars.example.yml dns-vars.yml cp gpg-vars.example.yml gpg-vars.yml cp k8s-vars.example.yml k8s-vars.yml @@ -112,6 +27,11 @@ To get started, follow the [installation](../README.md#installation) guide to se - Update the following values in the respective variable files: ```bash + # vars/user-vars.yml + username: "" # name of the user you want to setup on the target host + password: "" # password of the user you want to setup on the target host + path_to_ssh_key: "" # path to the ssh key on your machine + # vars/dns-vars.yml full_domain: "" # eg: laconic.com subdomain_prefix: "" # eg: lcn-cad @@ -140,7 +60,41 @@ To get started, follow the [installation](../README.md#installation) guide to se memory_reservation: "" # Minimum amount of memory in GB to be used, eg: 4G ``` -- Update `ansible_user` in the [`hosts.ini`](./hosts.ini) file to the user on target host +- 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 + [root_host] + ansible_host= ansible_user=root ansible_ssh_common_args='-o ForwardAgent=yes' + + [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 + - Under `deployment_host`, Replace `` with the name of the user you want to create + +- 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" + # } + ``` - Run the `service-provider-setup.yml` ansible-playbook to DNS records, deploy k8s, setup container registry, deploy the webapp-deployer API and webapp-deployer UI diff --git a/service-provider-setup/deploy-backend.yml b/service-provider-setup/deploy-backend.yml index dae513d..8919cc9 100644 --- a/service-provider-setup/deploy-backend.yml +++ b/service-provider-setup/deploy-backend.yml @@ -10,10 +10,6 @@ - vars/container-vars.yml - vars/k8s-vars.yml - vars/dns-vars.yml - - vars/user-vars.yml - - become: yes - become_user: "{{username}}" tasks: - name: Ensure gpg-keys directory exists diff --git a/service-provider-setup/deploy-frontend.yml b/service-provider-setup/deploy-frontend.yml index e45fbf4..59a8318 100644 --- a/service-provider-setup/deploy-frontend.yml +++ b/service-provider-setup/deploy-frontend.yml @@ -8,10 +8,6 @@ - vars/webapp-vars.yml - vars/dns-vars.yml - vars/k8s-vars.yml - - vars/user-vars.yml - - become: yes - become_user: "{{username}}" tasks: - name: Clone webapp-deployment-status-ui repository diff --git a/service-provider-setup/run-laconic-console.yml b/service-provider-setup/run-laconic-console.yml index d28e617..43655e7 100644 --- a/service-provider-setup/run-laconic-console.yml +++ b/service-provider-setup/run-laconic-console.yml @@ -8,10 +8,6 @@ - vars/webapp-vars.yml - vars/dns-vars.yml - vars/k8s-vars.yml - - vars/user-vars.yml - - become: yes - become_user: "{{username}}" tasks: - name: Clone the stack repo diff --git a/service-provider-setup/run-laconicd.yml b/service-provider-setup/run-laconicd.yml index 71ddf42..a148ca9 100644 --- a/service-provider-setup/run-laconicd.yml +++ b/service-provider-setup/run-laconicd.yml @@ -4,12 +4,6 @@ environment: PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin" - vars_files: - - vars/user-vars.yml - - become: yes - become_user: "{{username}}" - tasks: - name: Clone the fixturenet-laconicd-stack repo command: laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-laconicd-stack --pull diff --git a/service-provider-setup/setup-container-registry.yml b/service-provider-setup/setup-container-registry.yml index 3786e91..7b227e3 100644 --- a/service-provider-setup/setup-container-registry.yml +++ b/service-provider-setup/setup-container-registry.yml @@ -8,11 +8,7 @@ - vars/k8s-vars.yml - vars/container-vars.yml - vars/dns-vars.yml - - vars/user-vars.yml - become: yes - become_user: "{{username}}" - tasks: - name: Generate spec file for the container-registry stack template: diff --git a/service-provider-setup/setup-k8s.yml b/service-provider-setup/setup-k8s.yml index 56a60ce..e8d2d3e 100644 --- a/service-provider-setup/setup-k8s.yml +++ b/service-provider-setup/setup-k8s.yml @@ -12,10 +12,6 @@ - vars/dns-vars.yml - vars/gpg-vars.yml - vars/k8s-vars.yml - - vars/user-vars.yml - - become: yes - become_user: "{{username}}" tasks: - name: Install Python and pip diff --git a/service-provider-setup/setup-system.yml b/service-provider-setup/setup-system.yml index b45a8e7..b729e45 100644 --- a/service-provider-setup/setup-system.yml +++ b/service-provider-setup/setup-system.yml @@ -8,10 +8,6 @@ - vars/k8s-vars.yml - vars/dns-vars.yml - vars/gpg-vars.yml - - vars/user-vars.yml - - become: yes - become_user: "{{username}}" tasks: - name: Install required packages diff --git a/service-provider-setup/setup-user.yml b/service-provider-setup/setup-user.yml index 52533ea..da1b216 100644 --- a/service-provider-setup/setup-user.yml +++ b/service-provider-setup/setup-user.yml @@ -1,5 +1,5 @@ - name: Configure system - hosts: "{{ target_host }}" + hosts: root_host become: yes vars_files: