kevensen.oc

OC

This role includes a library for creating, changing, or removing objects in the OpenShift Container Platform. The oc.py library needs an OpenShift service account and a token for access and permissions.

Requirements

  • Ansible 2.3

Role Variables

  • There are no specific variables for this role.

Dependencies

This role needs a service account to be set up in each OpenShift cluster. You can do this with commands like:

$ oc project default
$ oc create serviceaccount ansible-sa
$ oadm policy add-cluster-role-to-user cluster-admin system:serviceaccount:default:ansible-sa

Note that the commands above will create a very powerful service account. It's best to adjust the access controls based on your needs.

Once the service account is created, OpenShift will automatically make a token as a secret. Use this token to create a variable for your playbooks.

Example Playbook

Here’s an example of how to delete a project:

---
# file: oc.yml
- hosts: oc
  roles:
  - role: kevensen.oc
  tasks:
  - name: Delete "{{ project_name }}" Project
    oc:
      state: absent
      name: "{{ project_name }}"
      kind: project
      token: abcdefg
      validate_certs: false
    register: result
  - debug:
      var: result
  any_errors_fatal: true
  vars:
    ansible_become: true
    project_name: ansibletest

License

  • GPLv3.

Author Information

  • Ken Evensen is a Solutions Architect at Red Hat.
Informazioni sul progetto

This self-contained role allows for the manipulation of resources in an OpenShift cluster.

Installa
ansible-galaxy install kevensen.oc
Licenza
Unknown
Download
111
Proprietario
Passionate about emerging technologies and cyber security