Skip to content

Commit 739f94b

Browse files
committed
docs: add kaktus support
1 parent e3b65ad commit 739f94b

8 files changed

Lines changed: 450 additions & 182 deletions

File tree

content/en/docs/admin-guide/create-kaktus.md

Lines changed: 277 additions & 45 deletions
Large diffs are not rendered by default.

content/en/docs/admin-guide/create-kiwi.md

Lines changed: 51 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Provisioning Kiwi
33
description: Let's provision our **Kiwi** instances
4-
weight: 4
4+
weight: 5
55
---
66

77
As detailed in [network topology](/docs/getting-started/topology/), we'll have 2 **Kiwi** instances:
@@ -19,81 +19,59 @@ Note that *10.50.101.1* and *10.50.102.1* will be used as virtual IPs (VIPs).
1919

2020
## Inventory Management
2121

22-
It is now time to declare your **Kiwi** instances in Ansible's inventory. Simply extend the **ansible/inventories/hosts.txt** the following way:
23-
24-
```ini
25-
[kiwi]
26-
10.50.101.2 name=kiwi-eu-west-1 region=eu-west ansible_ssh_user=ubuntu
27-
10.50.101.3 name=kiwi-eu-west-2 region=eu-west ansible_ssh_user=ubuntu
28-
```
22+
If required, update your **Kiwi** instances in Ansible's inventory.
2923

3024
{{< alert color="warning" title="Important" >}}
3125
Note that for the first-time installation, private IPs from the inventory are to replaced by the servers private ones (or anything in place which allows for bootstrapping machines).
3226
{{< /alert >}}
3327

34-
The instances are now declared to be part of **kiwi** group and Ansible will use **ubuntu** local user account to connect through SSH.
35-
36-
Note that doing so, you can now safely:
37-
38-
- declare host-specific variables in **ansible/host_vars/10.50.101.{2,3}.yml** files.
39-
- declare host-specific sensitive variables in **ansible/host_vars/10.50.101.{2,3}.sops.yml** file.
40-
- declare **kiwi** group-specific variables in **ansible/group_vars/kiwi/main.yml** file.
41-
- declare **kiwi** group-specific sensitive variables in **ansible/group_vars/kiwi.sops.yml** file.
42-
- declare any other global variables in **ansible/group_vars/all/main.yml** file.
43-
- declare any other global sensitive variables in **ansible/group_vars/all.sops.yml** file.
44-
45-
Note that Ansible variables precedence will apply:
46-
47-
```txt
48-
role defaults < all vars < group vars < host vars < role vars
49-
```
28+
The instances are now declared to be part of **kiwi**, **kiwi_eu_west** and **eu_west** groups.
5029

5130
## Network Configuration
5231

5332
We'll instruct the Ansible collection to provision network settings through [Netplan](https://netplan.io/). Note that our example is pretty simple, with only a single network interface to be used for private LAN, no link aggregation being used (recommended for enterprise-grade setups).
5433

55-
Let's declare the following configuration in **ansible/inventories/host_vars/10.50.101.2.yml** file:
34+
As the configuration is both instance-specific (private MAC address, IP address ...), region-specific (all **Kiwi** instance will do likely the same), and, as such, repetitive, we'll use some Ansible overlaying.
35+
36+
We've already declare quite a few stuff at region level when creating **eu-west** one.
37+
38+
Let's now extend the **ansible/inventories/group_vars/kiwi_eu_west/main.yml** file with the following:
5639

5740
```yaml
5841
kowabunga_netplan_config:
5942
ethernet:
60-
- name: "{{ wan_dev }}"
61-
mac: "aa:bb:cc:dd:ee:ff"
43+
- name: "{{ kowabunga_host_underlying_interface }}"
44+
mac: "{{ kowabunga_host_underlying_interface_mac }}"
6245
ips:
63-
- a.b.c.d/24
46+
- "4.5.6.{{ kowabunga_host_public_ip_addr_suffix }}/26"
6447
routes:
6548
- to: default
66-
via: e.c.d.f
67-
- name: "{{ lan_dev }}"
68-
mac: "aa:bb:cc:dd:ee:ff"
69-
vlan:
70-
# EU-WEST admin network
71-
- name: vlan101
72-
id: 101
73-
link: "{{ lan_dev }}"
74-
ips:
75-
- 10.50.101.2/24
76-
# EU-WEST storage network
77-
- name: vlan102
78-
id: 102
79-
link: "{{ lan_dev }}"
80-
ips:
81-
- 10.50.102.2/24
82-
# EU-WEST services networks
83-
- name: vlan201
84-
id: 201
85-
link: "{{ lan_dev }}"
86-
ips:
87-
- 10.50.201.2/24
88-
[...]
89-
- name: vlan209
90-
id: 209
91-
link: "{{ lan_dev }}"
92-
ips:
93-
- 10.50.209.2/24
49+
via: 4.5.6.1
50+
vlan: |
51+
{%- set res=[] -%}
52+
{%- for r in kowabunga_region_vlan_id_ranges -%}
53+
{%- for id in range(r.from, r.to + 1, 1) -%}
54+
{%- set dummy = res.extend([{"name": "vlan" + id | string, "id": id, "link": kowabunga_host_vlan_underlying_interface, "ips": [r.net_prefix | string + "." + id | string + "." + kowabunga_host_vlan_ip_addr_suffix | string + "/" + r.net_mask | string]}]) -%}
55+
{%- endfor -%}
56+
{%- endfor -%}
57+
{{- res -}}
9458
```
9559
96-
You'll need to ensure that the MAC addresses and host and gateway IP addresses are correctly set, depending on your setup. Once done, you can do the same for the alternate **Kiwi** instance in **ansible/inventories/host_vars/10.50.101.2.yml** file.
60+
As ugly as it looks, this Jinja macro will help us iterate over all the VLAN interfaces we need to create by simply taking a few instance-specific variables into consideration.
61+
62+
And that's exactly what we'll define in **ansible/inventories/host_vars/kiwi-eu-west-1** file:
63+
64+
```yaml
65+
kowabunga_primary_network_interface: eth0
66+
67+
kowabunga_host_underlying_interface: "{{ kowabunga_primary_network_interface }}"
68+
kowabunga_host_underlying_interface_mac: "aa:bb:cc:dd:ee:ff"
69+
kowabunga_host_vlan_underlying_interface: "{{ kowabunga_primary_network_interface }}"
70+
kowabunga_host_public_ip_addr_suffix: 202
71+
kowabunga_host_vlan_ip_addr_suffix: 2
72+
```
73+
74+
You'll need to ensure that the MAC addresses and host and gateway IP addresses are correctly set, depending on your setup. Once done, you can do the same for the alternate **Kiwi** instance in **ansible/inventories/host_vars/kiwi-eu-west-2.yml** file.
9775
9876
Extend the **ansible/inventories/group_vars/kiwi/main.yml** file with the following to ensure generic settings are propagated to all **Kiwi** instances:
9977
@@ -103,50 +81,35 @@ kowabunga_netplan_apply_enabled: true
10381
```
10482
10583
{{< alert color="success" title="Information" >}}
106-
Note that setting **kowabunga_netplan_disable_cloud_init** is an optional step. If you'd like to keep whatever configuration cloud-init has previously set, it's all fine (but it's always recommended not to have dual sourc eof truth).
84+
Note that setting **kowabunga_netplan_disable_cloud_init** is an optional step. If you'd like to keep whatever configuration cloud-init has previously set, it's all fine (but it's always recommended not to have dual source of truth).
10785
{{< /alert >}}
10886
10987
## Network Failover
11088
11189
Each **Kiwi** instance configuration is now set to receive host-specific network configuration. But they are meant to work in an HA-cluster, so let's define some redundancy rules. The two instances respectively bind the **.2** and **.3** private IPs from each subnet, but our active router will be **.1**, so let's define network failover configuration for that.
11290
113-
Again, extend the **ansible/inventories/group_vars/kiwi/main.yml** file with the following configuration:
91+
Again, extend the region-global **ansible/inventories/group_vars/kiwi_eu_west/main.yml** file with the following configuration:
11492
11593
```yaml
11694
kowabunga_kiwi_primary_host: "kiwi-eu-west-1"
95+
11796
kowabunga_network_failover_settings:
118-
peers: "{{ groups['kiwi'] }}"
97+
peers: "{{ groups['kiwi_eu_west'] }}"
11998
use_unicast: true
12099
trackers:
121100
- name: kiwi-eu-west-vip
122-
configs:
123-
- vip: 10.50.101.1/24
124-
vrid: 101
125-
primary: "{{ kowabunga_kiwi_primary_host }}"
126-
control_interface: vlan101
127-
interface: vlan101
128-
nopreempt: true
129-
- vip: 10.50.102.1/24
130-
vrid: 102
131-
primary: "{{ kowabunga_kiwi_primary_host }}"
132-
control_interface: vlan102
133-
interface: vlan102
134-
nopreempt: true
135-
- vip: 10.50.201.1/24
136-
vrid: 201
137-
primary: "{{ kowabunga_kiwi_primary_host }}"
138-
control_interface: vlan201
139-
interface: vlan201
140-
nopreempt: true
141-
[...]
142-
- vip: 10.50.209.1/24
143-
vrid: 209
144-
primary: "{{ kowabunga_kiwi_primary_host }}"
145-
control_interface: vlan209
146-
interface: vlan209
147-
nopreempt: true
101+
configs: |
102+
{%- set res = [] -%}
103+
{%- for r in kowabunga_region_vlan_id_ranges -%}
104+
{%- for id in range(r.from, r.to + 1, 1) -%}
105+
{%- set dummy = res.extend([{"vip": r.net_prefix | string + "." + id | string + ".1/" + r.net_mask | string, "vrid": id, "primary": kowabunga_kiwi_primary_host, "control_interface": kowabunga_primary_network_interface, "interface": "vlan" + id | string, "nopreempt": true}]) -%}
106+
{%- endfor -%}
107+
{%- endfor -%}
108+
{{- res -}}
148109
```
149110
111+
Once again, we interate over **kowabunga_region_vlan_id_ranges** variable to create our global configuration for **eu-west** region. After all, both **Kiwi** instances from there will have the very same configuration.
112+
150113
This will ensure that VRRP packets flows between the 2 peers so one always ends up being the active router for each virtual network interface.
151114
152115
## Firewall Configuration
@@ -184,8 +147,6 @@ kowabunga_firewall_wan_extra_nft_rules: []
184147
185148
with actual rules, depending on your network configuration and access means and policy (e.g. remote VPN access).
186149
187-
Once done with **Kiwi** deployment, let's move the [Kaktus](/docs/admin-guide/create-kaktus/) provisioning.
188-
189150
## PowerDNS Setup
190151
191152
{{< alert color="success" title="Information" >}}
@@ -198,26 +159,10 @@ This is a temporary measure only. Next stable versions of **Kiwi** will soon fea
198159
199160
In order to deploy and configure **PowerDNS** and its associated **MariaDB** database backend, one need to extend Ansible configuration.
200161
201-
Let's start by adding the following information to our **ansible/inventories/group_vars/all/main.yml** file:
202-
203-
```yaml
204-
domain_name: "{{ hostvars[inventory_hostname].region }}.acme.local"
205-
admin_domain_name: "admin.{{ domain_name }}"
206-
storage_domain_name: "storage.{{ domain_name }}"
207-
```
208-
209-
Let's now reflect these definitions into Kiwi's **ansible/inventories/group_vars/kiwi/main.yml** configuration file:
162+
Let's now reflect some definitions into Kiwi's **ansible/inventories/group_vars/kiwi_eu_west/main.yml** configuration file:
210163
211164
```yaml
212-
kowabunga_powerdns_locally_managed_zones:
213-
- "{{ domain_name }}"
214-
- "{{ admin_domain_name }}"
215-
- "{{ storage_domain_name }}"
216-
217165
kowabunga_powerdns_locally_managed_zone_records:
218-
- zone: "{{ domain_name }}"
219-
name: kiwi
220-
value: 10.50.101.1
221166
- zone: "{{ storage_domain_name }}"
222167
name: ceph
223168
value: 10.50.102.11
@@ -250,7 +195,7 @@ Finally, let's take care of **Kiwi** agent. The agent will establish its secured
250195
251196
Now remember that we previously used TF to [register new Kiwi agents](/docs/admin-guide/create-region/#kiwi-instances-and-agents). Once applied, emails were sent for each instance with a set of agent identifier and API key. These values now have to be provided to Ansible, as these are going to be the credentials used by **Kiwi** agent to connect to **Kahuna**.
252197
253-
So let's edit each Kiwi instance secrets file in respectively **ansible/inventories/host_vars/10.50.101.{2,3}.sops.yml** files:
198+
So let's edit each Kiwi instance secrets file in respectively **ansible/inventories/host_vars/kiwi-eu-west-{1,2}.sops.yml** files:
254199
255200
```yaml
256201
secret_kowabunga_kiwi_agent_id: AGENT_ID_FROM_KAHUNA_EMAIL_FROM_TF_PROVISIONING_STEP

content/en/docs/admin-guide/create-region.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,4 +394,28 @@ Once carefully reviewed, again, apply:
394394
$ kobra tf apply
395395
```
396396

397+
One more thing, let's reflect those changes in Ansible's configuration as well.
398+
399+
Simply extend your **ansible/inventories/group_vars/eu_west/main.yml** file the following way:
400+
401+
```yaml
402+
kowabunga_region: eu-west
403+
kowabunga_region_domain_admin_network: "10.50.101.0/24"
404+
kowabunga_region_domain_admin_router_address: 10.50.101.1
405+
kowabunga_region_domain_storage_network: "10.50.102.0/24"
406+
kowabunga_region_domain_storage_router_address: 10.50.102.1
407+
408+
kowabunga_region_vlan_id_ranges:
409+
- from: 101
410+
to: 102
411+
net_prefix: 10.50
412+
net_mask: 24
413+
- from: 201
414+
to: 209
415+
net_prefix: 10.50
416+
net_mask: 24
417+
```
418+
419+
This will help us provision the next steps ...
420+
397421
Let's continue and [provision our region's **Kiwi** instances](/docs/admin-guide/create-kiwi/) !
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Inventory Management
3+
description: Declaring Infrastructure Assets
4+
weight: 1
5+
---
6+
7+
Now let's suppose that you've cloned the Git platform repository template.
8+
9+
## Inventory Management
10+
11+
It is now time to declare your various instances in Ansible's inventory. Simply extend the **ansible/inventories/hosts.txt** the following way:
12+
13+
```ini
14+
##########
15+
# Global #
16+
##########
17+
18+
[kahuna]
19+
kowabunga-kahuna-1 ansible_host=10.0.0.1 ansible_ssh_user=ubuntu
20+
21+
##################
22+
# EU-WEST Region #
23+
##################
24+
25+
[kiwi_eu_west]
26+
kiwi-eu-west-1 ansible_host=10.50.101.2
27+
kiwi-eu-west-2 ansible_host=10.50.101.3
28+
29+
[kaktus_eu_west]
30+
kaktus-eu-west-a-1 ansible_host=10.50.101.11
31+
kaktus-eu-west-a-2 ansible_host=10.50.101.12
32+
kaktus-eu-west-a-3 ansible_host=10.50.101.13
33+
34+
[eu_west:children]
35+
kiwi_eu_west
36+
kaktus_eu_west
37+
38+
################
39+
# Dependencies #
40+
################
41+
42+
[kiwi:children]
43+
kiwi_eu_west
44+
45+
[kaktus:children]
46+
kaktus_eu_west
47+
```
48+
49+
In this example, we've declared our 6 instances (1 global **Kahuna**, 2 **Kiwi** and 3 **Kaktus** from EU-WEST region and their respective associated private IP addresses (used to deploy through SSH).
50+
51+
They respectively belong to various groups, and we've also created sub-groups. This is a special Ansible trick which will allow us to inherit variables from group each instance belongs to.
52+
53+
In that regard, considering the example of **kaktus-eu-west1**, the instance will be assigned variables from possibly various files. You can then safely:
54+
55+
- declare host-specific variables in **ansible/host_vars/kaktus-wu-west-1.yml** file.
56+
- declare host-specific sensitive variables in **ansible/host_vars/kaktus-eu-west-1.sops.yml** file.
57+
- declare **kaktus_eu_west** group-specific variables in **ansible/group_vars/kaktus_eu_west/main.yml** file.
58+
- declare **kaktus_eu_west** group-specific sensitive variables in **ansible/group_vars/kaktus_eu_west.sops.yml** file.
59+
- declare **kaktus** group-specific variables in **ansible/group_vars/kaktus/main.yml** file.
60+
- declare **kaktus** group-specific sensitive variables in **ansible/group_vars/kaktus.sops.yml** file.
61+
- declare **eu_west** group-specific variables in **ansible/group_vars/kaktus/eu_west.yml** file.
62+
- declare **eu_west** group-specific sensitive variables in **ansible/group_vars/eu_west.sops.yml** file.
63+
- declare any other global variables in **ansible/group_vars/all/main.yml** file.
64+
- declare any other global sensitive variables in **ansible/group_vars/all.sops.yml** file.
65+
66+
This way, instance can inherit variables from its global type (**kaktus**), its region (**eu_west**), and a mix of both (**kaktus_eu_west**).
67+
68+
Note that [Ansible variables precedence](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#understanding-variable-precedence) will apply:
69+
70+
```txt
71+
role defaults < all vars < group vars < host vars < role vars
72+
```
73+
74+
Let's take the time to also update the **ansible/inventories/group_vars/all/main.yml** file to update a few settings:
75+
76+
```yaml
77+
kowabunga_region_domain: "{{ kowabunga_region }}.acme.local"
78+
```
79+
80+
where **acme.local** would be your corporate private domain.

0 commit comments

Comments
 (0)