Skip to content

sys_use

Michal Opala edited this page Jun 27, 2023 · 19 revisions

Using the Playbooks

GitHub Project

The easiest way to use the playbooks is by cloning the GitHub project.

$ git clone https://github.com/OpenNebula/one-deploy.git

If you look closely at the ansible.cfg file in the root of the one-deploy repository and the directory structure you'll notice:

[defaults]
collections_paths=./ansible_collections/
$ stat ./ansible_collections/opennebula/deploy
  File: ./ansible_collections/opennebula/deploy -> ../../
  Size: 6         	Blocks: 0          IO Block: 4096   symbolic link

⚠️ Note: That effectively allows you to use files cloned from git as a "local" galaxy collection.

You can either use included Makefile or enter ansible-playbook commands directly.

To use this repo:

  1. Download requirements:
$ make requirements

OR

$ ansible-galaxy collection install --requirements-file requirements.yml
  1. Create your inventory file inside the inventory/ folder.

  2. Execute the provisioning:

$ make I=inventory/example.yml

OR

$ ansible-playbook -i inventory/example.yml opennebula.deploy.main
  1. Execute provisioning for specific tags:
$ make I=inventory/example.yml T=bastion,preinstall

OR

$ ansible-playbook -i inventory/example.yml opennebula.deploy.main --tags bastion,preinstall
  1. Proceed normally like with any other Ansible playbook. Thank you! 🤗

Ansible Galaxy Collection

For more advance users, the playbooks are available as part of the Ansible Galaxy community site, just take a look at the documentation of each role in the OpenNebula collection to include them in your own playbooks.

To install the opennebula.deploy collection directly from Ansible Galaxy execute:

$ ansible-galaxy collection install --upgrade opennebula.deploy

To deploy a full OpenNebula environment using playbooks downloaded together with the collection:

  1. Create your inventory folder:
$ mkdir ~/my-one/

$ cat > ~/my-one/example.yml <<'EOF'
---
all:
  vars:
    ansible_user: root
    one_version: '6.6'
    one_pass: opennebulapass
    vn:
      admin_net:
        managed: true
        template:
          VN_MAD: bridge
          PHYDEV: eth0
          BRIDGE: br0
          AR:
            TYPE: IP4
            IP: 172.20.0.100
            SIZE: 48
          NETWORK_ADDRESS: 172.20.0.0
          NETWORK_MASK: 255.255.255.0
          GATEWAY: 172.20.0.1
          DNS: 1.1.1.1

frontend:
  hosts:
    f1: { ansible_host: 172.20.0.6 }

node:
  hosts:
    n1: { ansible_host: 172.20.0.7 }
    n2: { ansible_host: 172.20.0.8 }
EOF

$ cat > ~/my-one/ansible.cfg <<'EOF'
[defaults]
inventory=./example.yml
gathering=explicit
host_key_checking=false
display_skipped_hosts=true
retry_files_enabled=false
any_errors_fatal=true
stdout_callback=yaml
timeout=30

[ssh_connection]
pipelining=true
ssh_args=-q -o ControlMaster=auto -o ControlPersist=60s
EOF
  1. Execute the main playbook:
$ (cd ~/my-one/ && ansible-playbook -v opennebula.deploy.main)
  1. You can also compose your own playbook or embed opennenebula.deploy.* roles into some existing automation. To for example run only SSH key provisioning, execute:
$ cat > keys.yml <<'EOF'
---
- hosts: frontend:node
  roles:
    - role: opennebula.deploy.helper.keys
EOF

$ (cd ~/my-one/ && ansible-playbook -v keys.yml)

Clone this wiki locally