On this page
oc - Manage OpenShift Resources
New in version 2.4.
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.
Options
parameter | required | default | choices | comments |
---|---|---|---|---|
host |
no | 127.0.0.1 |
Hostname or address of the OpenShift API endpoint. By default, this is expected to be the current inventory host.
|
|
inline |
no |
The inline definition of the resource. This is mutually exclusive with name, namespace and kind.
|
||
kind |
yes |
The kind of the resource upon which to take action.
|
||
name |
no |
The name of the resource on which to take action.
|
||
namespace |
no |
The namespace of the resource upon which to take action.
|
||
port |
no | 8443 |
The port number of the API endpoint.
|
|
state |
yes |
|
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 |
yes |
The token with which to authenticate agains the OpenShift cluster.
|
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 Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
method |
The HTTP method that was used to take action upon the resource
|
success | string | |
result |
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.
|
success | string | |
url |
The URL to the requested resource.
|
success | string |
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/oc_module.html