Skip to content

Commit

Permalink
F #98: Include opennebula-provision
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Jan 23, 2025
1 parent 83385a5 commit 3a89eab
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
3 changes: 3 additions & 0 deletions playbooks/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
- role: flow
tags: [flow]

- role: provision
tags: [provision]

- role: gui
tags: [gui]

Expand Down
39 changes: 39 additions & 0 deletions roles/provision/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Role: opennebula.deploy.flow
============================

A role that sets up the OneProvision utility.

Requirements
------------

N/A

| Name | Type | Default | Example | Description |
| --------------------------- | ----- | -------------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------ |
| `terraform_source` | `str` | https://releases.hashicorp.com/terraform/0.14.7/terraform_0.14.7_linux_amd64.zip | http://mirror.local/terraform.zip | Where to look the terraform zipped binary |
| `ansible_version_provision` | `str` | 2.15 | `2.18` | `ansible-core` pip package version |



Dependencies
------------

- opennebula.deploy.opennebula.common

Example Playbook
----------------

- hosts: frontend
roles:
- role: opennebula.deploy.helper.facts
- role: opennebula.deploy.provision

License
-------

Apache-2.0

Author Information
------------------

[OpenNebula Systems](https://opennebula.io/)
2 changes: 2 additions & 0 deletions roles/provision/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
terraform_source: https://releases.hashicorp.com/terraform/0.14.7/terraform_0.14.7_linux_amd64.zip
ansible_version_provision: '2.15.13'
6 changes: 6 additions & 0 deletions roles/provision/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
collections:
- opennebula.deploy

dependencies:
- role: opennebula.deploy.common
58 changes: 58 additions & 0 deletions roles/provision/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
- name: Install Terraform
ansible.builtin.unarchive:
src: "{{ terraform_source }}"
dest: /usr/local/bin
remote_src: true
mode: '0755'
creates: /usr/local/bin/terraform


- tags: [preinstall]
block:
- ansible.builtin.include_role:
name: repository
vars:
repos_enabled: [opennebula]
when: opennebula_repo is undefined

- name: Install OneProvision
ansible.builtin.package:
name: "{{ _common + _specific[ansible_os_family] }}"
vars:
_common: [opennebula-provision]
_specific:
Debian: []
RedHat: []
register: package
until: package is success
retries: 12
delay: 5

- name: Check Ansible version
ansible.builtin.shell:
cmd: |
version=$(ansible --version | head -n1)
if echo "$version" | grep -q "core"; then
echo "$version" | awk '{print $3}' | tr -d '[]'
else
echo "$version" | awk '{print $2}'
fi
register: ansible_version_check
changed_when: false

- name: Install required Ansible version
when: ansible_version_check.stdout is version(ansible_version_provision, '<')
block:
- name: Ensure python3-pip is installed
ansible.builtin.package:
name: python3-pip
state: present

- name: Install updated ansible version
ansible.builtin.pip:
name: "ansible-core>={{ ansible_version_provision }}"
state: present
become: true
become_user: oneadmin
ignore_errors: true # pipx error message might show

0 comments on commit 3a89eab

Please sign in to comment.