dmsimard / ansible-role-ci-centos

An Ansible role to provision and release ephemeral baremetal CI nodes from the ci.centos.org infrastructure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ansible-role-ci-centos

This role wraps around the Ansible module provided by python-cicoclient to request and release bare metal servers from the ci.centos.org system, Duffy.

Role variables

For default values, see defaults/main.yml

  • api_key: (Required) API Key to the ci.centos.org provisioning system (defaults to CICO_API_KEY environment variable)
  • private_key: (Required) Path to the SSH key to log on to ci.centos.org CI nodes (defaults to CICO_SSH_KEY environment variable)
  • endpoint: API endpoint for the ci.centos.org Duffy provisioning system
  • arch: Architecture of the requested nodes (ex: x86_64)
  • release: Release of the requested nodes (ex: 7)
  • count: Amount of nodes requested
  • ci_environment: Key that is set for traceability that execution is driven by a CI environment
  • rsync_server: rsync server to upload job artifacts to
  • rsync_password: Password to the artifact rsync server (usually determined from api_key)
  • jenkins_url: URL of the Jenkins instance (provided by Jenkins as an environment variable)
  • build_url: URL of the Jenkins build (provided by Jenkins as an environment variable)
  • job_name: Name of the Jenkins job (provided by Jenkins as an environment variable)
  • build_number: Number of the Jenkins build (provided by Jenkins as an environment variable)
  • log_root: Root directory where the debug logs are located (so we can upload them)
  • log_destination: Subdirectory where the debug logs are located (so we can upload them)

Included tasks

  • provision: Requests a node of the provided specifications
  • release: Release the nodes tied to the current session

Example playbook

- name: Provision a ci.centos.org node
  hosts: localhost
  roles:
    - { role: "ci-centos", action: "provision" }

# Do something with it

- name: Release the provisioned ci.centos.org nodes
  hosts: openstack_nodes
  roles:
    - { role: "ci-centos", action: "release" }

Important notes

The ci.centos.org provisioning system may only be used from within their network infrastructure. This means you can only run this role on, for example, a Jenkins slave that was provided by their team.

If you provision a node, you need to destroy it in the same playbook or it will leak. This means you have to release it as the last step of the playbook (as shown above) AND handle errors in your playbooks.

WeIRDO uses this role and handles errors with the block feature from Ansible 2. The implementation looks like this:

There is an issue opened with Ansible to try and improve how rescue blocks can be use to make this use case far simpler.

About

An Ansible role to provision and release ephemeral baremetal CI nodes from the ci.centos.org infrastructure