From 82ce1d08ee69d96b08730d8049b88411167efceb Mon Sep 17 00:00:00 2001 From: Adw8 Date: Tue, 24 Sep 2024 14:56:23 +0530 Subject: [PATCH] Add playbook for setting up service provider --- service-provider-setup/.gitignore | 5 +- service-provider-setup/README.md | 120 +++++------------- service-provider-setup/deploy-backend.yml | 5 + .../service-provider-setup.yml | 7 + service-provider-setup/setup-k8s.yml | 11 +- .../vars/webapp-vars.example.yml | 4 +- 6 files changed, 47 insertions(+), 105 deletions(-) create mode 100644 service-provider-setup/service-provider-setup.yml diff --git a/service-provider-setup/.gitignore b/service-provider-setup/.gitignore index a27004d..26614fb 100644 --- a/service-provider-setup/.gitignore +++ b/service-provider-setup/.gitignore @@ -1,4 +1 @@ -vars/dns-vars.yml -vars/k8s-vars.yml -vars/container-vars.yml -vars/webapp-vars.yml +vars/*.yml diff --git a/service-provider-setup/README.md b/service-provider-setup/README.md index 605c17b..a3b8145 100644 --- a/service-provider-setup/README.md +++ b/service-provider-setup/README.md @@ -45,9 +45,7 @@ To get started, follow the [installation](../README.md#installation) guide to se ansible-playbook setup-user.yml -i hosts.ini --extra-vars='{ "target_host": "deployment_host" }' ``` -For the following playbooks, Update `ansible_user` in the [`hosts.ini`](./hosts.ini) file to the user that you created - -## Configure DNS +## Become a Service Provider ### Prerequisites @@ -55,43 +53,6 @@ For the following playbooks, Update `ansible_user` in the [`hosts.ini`](./hosts. - Generate a DigitalOcean access token -### Create DNS entries in DigitalOcean - -- Copy the [`dns-vars.example.yml`](./vars/dns-vars.example.yml) file - - ```bash - cd vars - cp dns-vars.example.yml dns-vars.yml - ``` - -- Set the following values in the `dns-vars.yml` file - - ```bash - # primary domain for which DNS records will be managed - # eg: laconic.com - domain: "" - - # specific prefix for subdomains - # eg: lcn-cad - subdomain_prefix: "" - - # The IP address to be used for the A record of the cluster control machine - # eg: 23.111.78.179 - cluster_control_ip: "" - - # DigitalOcean access token - # eg: dop_v1... - do_api_token: "" - ``` - -- Run the [`setup-dns.yml`](./setup-dns.yml) ansible playbook to create the necessary DNS entries in DigitalOcean - - ```bash - ansible-playbook setup-dns.yml - ``` - -## Setup k8s clusters - - Create a PGP key on your target host ``` @@ -114,70 +75,47 @@ For the following playbooks, Update `ansible_user` in the [`hosts.ini`](./hosts. uid [ultimate] user ``` - Note the `0AFB10B643944C22` sequence of characters. + Note the `0AFB10B643944C22` sequence of characters. This will be required later. -- Copy the [`k8s-vars.example.yml`](./vars/k8s-vars.example.yml) file +- Copy the vars files: ```bash cd vars - cp k8s-vars.example.yml k8s-vars.yml + cp dns-vars.example.yml dns1-vars.yml + cp k8s-vars.example.yml k8s1-vars.yml + cp container-vars.example.yml container1-vars.yml + cp webapp-vars.example.yml webapp-vars.yml ``` -- Update `gpg_key_id` in [`k8s-vars.yml`](./vars/k8s-vars.yml) with the the following: +- Update the following values in the respective variable files: ```bash + # vars/dns-vars.yml + domain: "" # eg: laconic.com + subdomain_prefix: "" # eg: lcn-cad + cluster_control_ip: "" # eg: 23.111.78.179 + do_api_token: "" # eg: dop_v1... + + # vars/k8s-vars.yml target_host: "deployment_host" + gpg_key_id: "" # The sequence obtained in the previous step, eg: 0AFB10B643944C22 + vault_passphrase: "" # passphrase for GPG key + org_id: "" # eg: lcn + location_id: "" # eg: cad + dns_domain: "" # eg: laconic.com - # The sequence you obtained in the previous step - # eg: 0AFB10B643944C22 - gpg_key_id: "" + # vars/container-vars.yml + container_registry_username: "" # username to login to the container registry + container_registry_password: "" # password to login to the container registry - # The passphrase used while creating the GPG key - vault_passphrase: "" - - # Three letter identifier for your organization - # eg: lcn - org_id: "" - - # Three letter identifier for your location - # eg: cad - location_id: "" - - # your domain - dns_domain: "" + # vars/webapp-vars.yml + authority_name: "" # eg: my-org-name ``` -- Run the `setup-k8s.yml` ansible playbook: +- Update `ansible_user` in the [`hosts.ini`](./hosts.ini) file to the user on target host + +- 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 ```bash - ansible-playbook setup-k8s.yml -i hosts.ini --extra-vars='{ target_host: "deployment_host" }' --user $USER + ansible-playbook service-provider-setup.yml -i hosts.ini --extra-vars='{ target_host: "deployment_host" }' --user $USER ``` - -## Setup Container Registry - -- Copy the [`container-vars.example.yml`](./vars/container-vars.example.yml) file - - ```bash - cd vars - cp container-vars.example.yml container-vars.yml - ``` - -- Update the following in the [`container-vars.yml`](./vars/container-vars.yml) file: - - ```bash - # username for the container registry - container_registry_username: "" - - # password for the container registry - container_registry_password: "" - ``` - -- Run the `setup-container-registry.yml` ansible playbook - - ```bash - ansible-playbook setup-container-registry.yml -i hosts.ini --extra-vars='{ target_host: "deployment_host" }' --user $USER - ``` - -## Setup laconicd and laconic console - -- \ No newline at end of file diff --git a/service-provider-setup/deploy-backend.yml b/service-provider-setup/deploy-backend.yml index 04c7c2e..d9bf91c 100644 --- a/service-provider-setup/deploy-backend.yml +++ b/service-provider-setup/deploy-backend.yml @@ -35,6 +35,11 @@ - name: Build containers for webapp-deployer-backend command: laconic-so --stack webapp-deployer-backend build-containers + - name: Ensure the config directory exists + file: + path: "{{ ansible_env.HOME }}/config" + state: directory + - name: Create laconic config file template: src: "./templates/laconic.yml.j2" diff --git a/service-provider-setup/service-provider-setup.yml b/service-provider-setup/service-provider-setup.yml new file mode 100644 index 0000000..a50564d --- /dev/null +++ b/service-provider-setup/service-provider-setup.yml @@ -0,0 +1,7 @@ +- import_playbook: setup-dns.yml +- import_playbook: setup-k8s.yml +- import_playbook: setup-container-registry.yml +- import_playbook: run-laconicd.yml +- import_playbook: run-laconic-console.yml +- import_playbook: deploy-backend.yml +- import_playbook: deploy-frontend.yml diff --git a/service-provider-setup/setup-k8s.yml b/service-provider-setup/setup-k8s.yml index 66bbee9..bfec933 100644 --- a/service-provider-setup/setup-k8s.yml +++ b/service-provider-setup/setup-k8s.yml @@ -58,16 +58,11 @@ command: gpg-agent --daemon ignore_errors: yes - - name: Set VAULT_KEY environment variable - shell: export VAULT_KEY='{{ vault_passphrase }}' + - name: Sign a dummy string using gpg-key + shell: echo "This is a dummy string." | gpg --batch --yes --passphrase "{{ vault_passphrase }}" --pinentry-mode loopback --sign - - name: Run vault-rekey.sh - expect: - command: bash .vault/vault-rekey.sh - responses: - "Enter passphrase:": "{{ vault_passphrase }}" - environment: - VAULT_KEY='{{ vault_passphrase }}' + shell: bash .vault/vault-rekey.sh args: chdir: "service-provider-template" diff --git a/service-provider-setup/vars/webapp-vars.example.yml b/service-provider-setup/vars/webapp-vars.example.yml index ede7205..5c632f1 100644 --- a/service-provider-setup/vars/webapp-vars.example.yml +++ b/service-provider-setup/vars/webapp-vars.example.yml @@ -1,3 +1,3 @@ authority_name: "" -ALICE_PK: "" -BOND_ID: "" +ALICE_PK: "{{ ALICE_PK }}" +BOND_ID: "{{ BOND_ID }}"