## CloudStack with Ansible
CSEUG 2022

---
## Who am I?
- René Moser (aka resmo)
- Apache CloudStack PMC
- Ansible Integrations
- Apache CloudStack
- Vultr
- Cloudscale
---

Engineering Cloud Computing
Automation, Integration, Scaling.
ngine.io
---

---
## Agenda
- History
- Brief intro
- Demo
---
## Some History
---
### 2013 July
- Puppet Engineer
- Swiss National Broadcast Union
---
### 2014 September
- Hacking first modules
---
### 2015 April
- First few plugins merged upstream
- Testing Simulator
- Goal: Fully configure ClouStack from zero
---
### 2020
- Rafael from Celpax reached my goal
- 53 plugins
- \>85 test coverage
---
### Future
- Catch up with CloudStack API
- Increase test coverage and test unreleased CloudStack
- Refactor modules with learnings
- Provide a "Out of the Box CloudStack"
---
## Ansible
---
### Ansible
- CLI
- SSH agentless
- Python
---
## Why Ansible?
---
### Extensible
Everything is a plugin
---
### Batteries included
\>6600 task plugins included
---
### Flexible
---
## When not Ansible?
- != A toolbox / framework
- != Linux / CLI
- != YAML
---
## Ansible "Modus Operandi"
- Controller with Ansible
- Inventory (list of hosts)
- Playbooks (list of tasks)
---
```mermaid
graph TD
A[Controller]
A -->|SSH| B[web1]
A -->|SSH| C[web2]
A -->|SSH| D[web3]
```
---
```mermaid
graph TD
A[Controller] -->|HTTP| C(API)
```
---
```mermaid
graph TD
A[Controller] -->|HTTP| C(API)
C --> D[web1]
C --> E[web2]
C --> F[web3]
```
---
```mermaid
graph TD
A[Controller] -->|HTTP| C(API)
C --> D[web1]
C --> E[web2]
C --> F[web3]
A -->|SSH| F
```
---
```mermaid
graph TD
A[Controller] -->|HTTP| C(API)
C --> B[security groups]
C --> D[security rules]
C --> E[networks]
C --> F[ssh keys]
C --> G[affinity groups]
C --> H[...]
```
---
### Ansible Idempotency
You get ~ what you define.
---
```yaml
- name: Ensure instance created
ngine_io.cloudstack.cs_instance:
display_name: web1
zone: fra1
template: "Linux Debian 11 64-bit"
service_offering: Tiny
ssh_key: john@example.com
user_data: |
#cloud-config
packages:
- nginx
state: present
```
---
```mermaid
graph LR
A[START] --> B(find) --> C{found?} -->|no| D(create)
C -->|yes| E{different?}
E -->|no| F(return)
E -->|yes| G(update)
G --> F
D --> F
F --> H[END]
```
---
```yaml
- name: Ensure instance created
ngine_io.cloudstack.cs_instance:
display_name: web1
zone: fra1
template: "Linux Debian 11 64-bit"
service_offering: Tiny
force: true
ssh_key: john@example.com
user_data: |
#cloud-config
packages:
- nginx
state: started
```
---
### Ansible Role
- Dir structure of tasks/templates/files/...
- Packacke format
- Configurable with defaults
---
### Ansible Role Exoscale
- Exoscale Public Cloud
- ngine_io.exoscale_compute
---
### Contact
You can find me on
- GitHub: gh/resmo
- Twitter: @resmo79
- Web: https://renemoser.net
---
## Demo Ansible
- See a typical Ansible setup
- Deploy 2 stages (staging, prod)
- Show idempotency (stop VM, offering change)
{"metaMigratedAt":"2023-06-16T22:40:48.057Z","metaMigratedFrom":"YAML","title":"CloudStack with Ansible","breaks":true,"description":"View the slide with \"Slide Mode\".","contributors":"[{\"id\":\"4f12f2ea-eb5d-4395-a9a8-8cf5af5b2c6c\",\"add\":3253,\"del\":1521}]"}