Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobdotcosta committed Nov 7, 2023
1 parent af67a37 commit c69ca44
Show file tree
Hide file tree
Showing 29 changed files with 77 additions and 70 deletions.
87 changes: 33 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,71 +12,50 @@ Cloud infrastructure provisioning.

* Manages OpenStack VMs

## Requirements
## Ansible compatibility

Ansible Collections:
This collection has been tested against Ansible `2.9.10`.

## Installation

To use this collection it must be first installed.

This can performed by using the Ansible CLI directly.

```bash
ansible-galaxy collection install snowdrop.cloud_infra
```

Another way to install this collection is using a `requirements.yml` file.

```yaml
---
collections:
- name: openstack.cloud
version: 2.1.0
- name: snowdrop.cloud_infra
```
## Role Variables
Then install the this file using the following command.
OpenStack VM role required parameters
```bash
ansible-galaxy collection install -r requirements.yml --upgrade
```

| Parameter | Comments |
|-----------|------------|
| `rhos_auth` <br/> $\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | Map with the authentication |
| `rhos_auth_type` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | RHOS Authentication type <sup>1)</sup> |
| `openstack_security_group` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | Security group |
| `state` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | State of the VM <br/> * `present` <br/> * `absent` |
| `vm_name` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | Name of the VM to be created |
## Roles

<sup>1)</sup> More information on the available keystone plugins on the
[RHOS documentation](https://docs.openstack.org/keystoneauth/latest/plugin-options.html#available-plugins).

The `rhos_auth` Map parameter must contain the required attributes for a successfull
authentication as selected with the `rhos_auth_type` variable.

For a `v3password` authentication the required contents are the following.
* [openstack_vm](roles/openstack_vm): provision OpenStack virtual machines

| Name | Comments |
|-------|-----------------------------------|
| `auth_url` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | Service authentication URL |
| `password` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | Console login user |
| `project_domain_name` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | Project domain |
| `project_name` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | Tenant domain |
| `user_domain_name` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | User domain |
| `username` <br/>$\color{fuchsia}{\textsf{map}}$ / $\color{red}{\textsf{required}}$ | Console login user |
## Usage

Output:
* `openstack_vm_ipv4`
* `openstack_output`
To create a VM on an OpenStack project check the [`create_vm` playbook](playbooks/create_vm.yml).

## Example
To remove a VM from an OpenStack project check the [`remove_vm` playbook](playbooks/create_vm.yml).

Sample playbook:
## License

```yaml
- name: "Create VM on OpenStack"
hosts: localhost
gather_facts: True
tasks:
- name: "Create VM"
ansible.builtin.include_role:
name: "snowdrop.cloud_infra.openstack_vm"
vars:
rhos_auth:
auth_url:
project_name:
username:
password:
user_domain_name:
project_domain_name:
rhos_auth_type: v3password
state: present
vm_name: snowdrop-vm
```
Apache License 2.0

Check the [LICENSE](LICENSE) to view the full text.

## Author Information

This role has been created by the [Snowdrop team](https://github.com/snowdrop/).
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ openstack_defaults:
name: "{{ hostname }}"
image: Fedora-Cloud-Base-35
key_name: "{{ hostname }}"
flavor: m1.medium
flavor: m1.small
network: default_network
security_group: default_security_group
# Array of items with 2 attributes, name and size
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions molecule/github/roles
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
- name: "Validate server IPV4"
ansible.builtin.assert:
that:
- openstack_server_info_output.servers[0].access_ipv4 is defined and openstack_server_info_output.servers[0].access_ipv4 | length > 0
- openstack_vm_ipv4 is defined and openstack_vm_ipv4 | length > 0
msg: "Openstack server must have an IPV4. "

- name: "Validate server flavor"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ openstack_defaults:
name: "{{ hostname }}"
image: Fedora-Cloud-Base-35
key_name: "{{ hostname }}"
flavor: m1.medium
flavor: m1.small
network: default_network
security_group: default_security_group
# Array of items with 2 attributes, name and size
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dependency:
driver:
name: default
# name: delegated
# name: docker
platforms:
- name: instance
image: docker.io/pycontribs/centos:8
Expand Down
1 change: 1 addition & 0 deletions molecule/local-default-key/roles
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
- name: "Validate server IPV4"
ansible.builtin.assert:
that:
- openstack_server_info_output.servers[0].access_ipv4 is defined and openstack_server_info_output.servers[0].access_ipv4 | length > 0
- openstack_vm_ipv4 is defined and openstack_vm_ipv4 | length > 0
msg: "Openstack server must have an IPV4. "

- name: "Validate server flavor"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ openstack_defaults:
name: "{{ hostname }}"
image: Fedora-Cloud-Base-35
key_name: "{{ hostname }}"
flavor: m1.medium
flavor: m1.small
network: default_network
security_group: default_security_group
# Array of items with 2 attributes, name and size
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
dependency:
name: galaxy
driver:
name: delegated
name: default
# name: delegated
# name: docker
platforms:
- name: instance
Expand Down
1 change: 1 addition & 0 deletions molecule/local-vm-key/roles
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
- name: "Validate server IPV4"
ansible.builtin.assert:
that:
- openstack_server_info_output.servers[0].access_ipv4 is defined and openstack_server_info_output.servers[0].access_ipv4 | length > 0
- openstack_vm_ipv4 is defined and openstack_vm_ipv4 | length > 0
msg: "Openstack server must have an IPV4. "

- name: "Validate server flavor"
Expand Down
8 changes: 8 additions & 0 deletions molecule/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#molecule[docker,lint]
molecule-plugins[docker]
yq
ansible-lint
#molecule-lint
molecule-docker
#molecule-podman
lint
11 changes: 11 additions & 0 deletions playbooks/create_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: "Create VM on OpenStack"
hosts: localhost
gather_facts: True

tasks:
- name: "Create VM"
ansible.builtin.include_role:
name: "snowdrop.cloud_infra.openstack_vm"
vars:
state: present
vm_name: snowdrop-vm
11 changes: 11 additions & 0 deletions playbooks/remove_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: "Remove VM on OpenStack"
hosts: localhost
gather_facts: True

tasks:
- name: "Remove VM"
ansible.builtin.include_role:
name: "snowdrop.cloud_infra.openstack_vm"
vars:
state: absent
vm_name: snowdrop-vm
11 changes: 2 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
molecule[docker,lint]
openstacksdk >= 1.2.0
#python-openstackclient >= 6.2.0
yq
ansible >= 2.9.10
ansible-lint
#molecule-lint
molecule-docker
#molecule-podman
lint
openstacksdk >= 2.0.0
#python-openstackclient >= 6.2.0

0 comments on commit c69ca44

Please sign in to comment.