-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,168 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,3 @@ notes.txt | |
ansible.cfg | ||
.yamlfmt | ||
.run.sh | ||
|
||
roles/deploy/files/resources | ||
roles/deploy/files/lard_ingestion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ ansible-galaxy collection install -fr requirements.yml | |
|
||
You need to create application credentials in the project you are going to | ||
create the instances in, so that the ansible scripts can connect to the right | ||
ostack_cloud which in our case needs to be called lard. | ||
`ostack_cloud` which in our case needs to be called lard. | ||
|
||
The file should exist in `~/.config/openstack/clouds.yml`. | ||
If have MET access see what is written at the start of the readme [here](https://gitlab.met.no/it/infra/ostack-ansible21x-examples) | ||
|
@@ -34,32 +34,55 @@ Go to "Compute" then "Key Pairs" and import your public key for use in the provi | |
|
||
### Provision! | ||
|
||
The IPs in `inventory.yml` should correspond to floating ips you have requested | ||
in the network section of the open stack GUI. If you need to delete the old VMs | ||
(compute -> instances) and Volumes (volumes -> volumes) you can do so in the | ||
ostack GUI. | ||
The IPs associated to the hosts in `inventory.yml` should correspond to | ||
floating ips you have requested in the network section of the open stack GUI. | ||
If you need to delete the old VMs (compute -> instances) and Volumes (volumes | ||
-> volumes) you can do so in the ostack GUI. | ||
|
||
> \[!CAUTION\] For some reason when deleting things to build up again one of the IPs | ||
> did not get disassociated properly, and I had to do this manually (network -> | ||
> floating IPs). | ||
> \[!CAUTION\] When deleting things to build up again, if for some reason one of the IPs | ||
> does not get disassociated properly, you have to do it manually from the GUI (network -> floating IPs). | ||
The vars for the network and addssh tasks are encrypted with ansible-vault | ||
(ansible-vault decrypt roles/networks/vars/main.yml, ansible-vault decrypt | ||
roles/addshhkeys/vars/main.yml, ansible-vault decrypt | ||
roles/vm_format/vars/main.yml). But if this has been setup before in the ostack | ||
project, these have likely already been run and therefore already exits so you | ||
could comment out this role from provision.yml. Passwords are in [ci_cd variables](https://gitlab.met.no/met/obsklim/bakkeobservasjoner/lagring-og-distribusjon/db-products/poda/-/settings/ci_cd). | ||
The vars for the `network` and `addssh` roles are encrypted with ansible-vault | ||
|
||
```terminal | ||
ansible-playbook -i inventory.yml -e ostack_key_name=xxx provision.yml | ||
ansible-vault decrypt roles/networks/vars/main.yml | ||
ansible-vault decrypt roles/addsshkeys/vars/main.yml | ||
ansible-vault decrypt roles/vm_format/vars/main.yml | ||
``` | ||
|
||
But if this has been setup before in the ostack project, these have likely | ||
already been run and therefore already exits so you could comment out this role | ||
from `provision.yml`. | ||
Passwords are in [ci_cd variables](https://gitlab.met.no/met/obsklim/bakkeobservasjoner/lagring-og-distribusjon/db-products/poda/-/settings/ci_cd). | ||
|
||
```terminal | ||
ansible-playbook -i inventory.yml -e ostack_key_name=xxx provision.yml | ||
``` | ||
|
||
After provisioning the next steps may need to ssh into the hosts, and thus you need to add them to your known hosts. | ||
Ansible appears to be crap at this, so its best to do it before running the next step by going: | ||
`ssh [email protected].*.*` | ||
For all the VMs. | ||
Ansible appears to be crap at this, so its best to do it before running the next step. | ||
First of all, it might be helpful to create host aliases and add them to your `~/.ssh/config` file, | ||
so you don't have to remember the IPs by heart. An example host alias looks like the following: | ||
|
||
```ssh | ||
Host lard-a | ||
HostName 157.249.*.* | ||
User ubuntu | ||
``` | ||
|
||
Then run: | ||
|
||
```terminal | ||
ssh lard-a | ||
ssh lard-b | ||
``` | ||
|
||
If cleaning up from tearing down a previous set of VMs you may also need to remove them first: | ||
`ssh-keygen -f "/home/louiseo/.ssh/known_hosts" -R "157.249.*.*"` | ||
|
||
```terminal | ||
ssh-keygen -f "~/.ssh/known_hosts" -R lard-a | ||
ssh-keygen -f "~/.ssh/known_hosts" -R lard-b | ||
``` | ||
|
||
### Configure! | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
--- | ||
- name: Deploy binaries | ||
# Deploy on both VMs, only the primary is "active" | ||
hosts: servers | ||
remote_user: ubuntu | ||
gather_facts: false | ||
# All role tasks require root user | ||
become: true | ||
roles: | ||
- role: deploy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
ostack_cloud: lard | ||
ostack_state: present | ||
ostack_region: Ostack2-EXT | ||
ostack2: true | ||
|
||
# networks | ||
ostack_network_name: "{{ vault_ostack_network_name }}" | ||
ostack_network_cidr: "{{ vault_ostack_network_cidr }}" | ||
ostack_netword_dns: "{{ vault_ostack_netword_dns }}" | ||
ostack_network_security_groups: "{{ vault_ostack_network_security_groups }}" | ||
ostack_ipalias_network_cidr: "{{ vault_ostack_ipalias_network_cidr }}" | ||
|
||
# vm_create | ||
ostack_vm_flavor: "{{ vault_ostack_flavor }}" | ||
ostack_vm_image: "{{ vault_ostack_image }}" | ||
ostack_vm_security_groups: "{{ vault_ostack_security_groups }}" | ||
ostack_vm_volume_type: "{{ vault_ostack_volume_type }}" | ||
ostack_vm_volume_size: "{{ vault_ostack_volume_size }}" | ||
# ostack_vm_key_name: provide via cmd | ||
|
||
# vm_format | ||
ostack_mount_device: "{{ vault_ostack_mount_device }}" | ||
ostack_mount_point: "/mnt/ssd-data" | ||
|
||
# ssh | ||
ssh_user_key_list: "{{ vault_ssh_user_key_list }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
--- | ||
- name: Setup networks and 2 vms | ||
- name: Provision | ||
hosts: servers | ||
gather_facts: false | ||
vars: | ||
ostack_vm_key_name: # provide via cmd | ||
|
||
tasks: | ||
- name: Setup networks # noqa: run-once[task] | ||
- name: Setup networks | ||
ansible.builtin.include_role: | ||
name: networks | ||
name: ostack | ||
tasks_from: networks.yml | ||
delegate_to: localhost | ||
run_once: true | ||
|
||
- name: Setup VMs | ||
- name: Create VMs | ||
ansible.builtin.include_role: | ||
name: vm | ||
name: ostack | ||
tasks_from: vm_create.yml | ||
delegate_to: localhost |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
--- | ||
# TODO: separate what should be public and what private | ||
|
||
# public | ||
# PUBLIC | ||
ostack_cloud: lard | ||
ostack_region: Ostack2-EXT | ||
ostack_ipalias_network_name: ipalias | ||
# ostack_state: present | ||
ostack_state: present | ||
|
||
# private | ||
## networks | ||
# PRIVATE | ||
# networks | ||
ostack_network_name: | ||
|
||
# TODO: probably makes sense to move these to network if they are not reused | ||
# and networks_dns should be moved here since it depends on ostack_region | ||
ostack_cidr: | ||
ostack_ipalias_cidr: | ||
ostack_security_groups: | ||
ostack_network_cidr: | ||
ostack_netword_dns: # dict[ostack_region -> list(ipv4)] | ||
ostack_network_security_groups: | ||
- name: | ||
rule: | ||
subnet: | ||
port: | ||
ostack_ipalias_network_cidr: | ||
|
||
# vm_create | ||
ostack_vm_image: | ||
ostack_vm_flavor: | ||
ostack_vm_key_name: | ||
ostack_vm_security_groups: | ||
ostack_vm_volume_type: | ||
ostack_vm_volume_size: | ||
|
||
# vm_format | ||
ostack_mount_device: | ||
ostack_mount_point: | ||
ostack_repmgr_password: | ||
|
||
## vm | ||
ostack_availability_zone: | ||
ostack_image: | ||
ostack_flavor: | ||
ostack_key_name: | ||
# create_primary / create_standby | ||
ostack_db_password: | ||
ostack_primary_floating_ip: | ||
ostack_primary_ip: |
Oops, something went wrong.