oc – Manage OpenShift Resources

New in version 2.4.

DEPRECATED

Removed in Ansible

version: 2.9

Why

This module used the oc command line tool, where as openshift_raw goes over the REST API.

Alternative

Use openshift_raw instead.

Synopsis

  • This module allows management of resources in an OpenShift cluster. The inventory host can be any host with network connectivity to the OpenShift cluster; the default port being 8443/TCP.

  • This module relies on a token to authenticate to OpenShift. This can either be a user or a service account.

Parameters

Parameter Choices/Defaults Comments
host
-
Default:
"127.0.0.1"
Hostname or address of the OpenShift API endpoint. By default, this is expected to be the current inventory host.
inline
-
The inline definition of the resource. This is mutually exclusive with name, namespace and kind.

aliases: def, definition
kind
- / required
The kind of the resource upon which to take action.
name
-
The name of the resource on which to take action.
namespace
-
The namespace of the resource upon which to take action.
port
-
Default:
8443
The port number of the API endpoint.
state
- / required
    Choices:
  • present
  • absent
If the state is present, and the resource doesn't exist, it shall be created using the inline definition. If the state is present and the resource exists, the definition will be updated, again using an inline definition. If the state is absent, the resource will be deleted if it exists.
token
- / required
The token with which to authenticate against the OpenShift cluster.
validate_certs
boolean
    Choices:
  • no
  • yes ←
If no, SSL certificates for the target url will not be validated. This should only be used on personally controlled sites using self-signed certificates.

Examples

- name: Create project
  oc:
    state: present
    inline:
      kind: ProjectRequest
      metadata:
        name: ansibletestproject
      displayName: Ansible Test Project
      description: This project was created using Ansible
    token: << redacted >>

- name: Delete a service
  oc:
    state: absent
    name: myservice
    namespace: mynamespace
    kind: Service
    token: << redacted >>

- name: Add project role Admin to a user
  oc:
    state: present
    inline:
      kind: RoleBinding
      metadata:
        name: admin
        namespace: mynamespace
      roleRef:
        name: admin
      userNames:
        - "myuser"
      token: << redacted >>

- name: Obtain an object definition
  oc:
   state: present
   name: myroute
   namespace: mynamespace
   kind: Route
   token: << redacted >>

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
method
string
success
The HTTP method that was used to take action upon the resource

result
string
success
The resource that was created, changed, or otherwise determined to be present. In the case of a deletion, this is the response from the delete request.

url
string
success
The URL to the requested resource.



Status

  • This module will be removed in version 2.9. [deprecated]

  • For more information see DEPRECATED.

Authors

  • Kenneth D. Evensen (@kevensen)

Hint

If you notice any issues in this documentation you can edit this document to improve it.