Este conteúdo não está disponível no idioma selecionado.
Chapter 12. Ansible Automation Platform Resource Operator
12.1. Resource Operator overview Copiar o linkLink copiado para a área de transferência!
Resource Operator is a custom resource (CR) that you can deploy after you have created your platform gateway deployment.
With Resource Operator you can define resources such as projects, job templates, and inventories in YAML files.
automation controller then uses the YAML files to create these resources. You can create the YAML through the Form view that prompts you for keys and values for your YAML code. Alternatively, to work with YAML directly, you can select YAML view.
The Resource Operator provides the following CRs:
- AnsibleJob
- JobTemplate
- Automation controller project
- Automation controller schedule
- Automation controller workflow
- Automation controller workflow template:
- Automation controller inventory
- Automation controller credential
For more information on any of the above custom resources, see Using automation execution.
12.2. Using Resource Operator Copiar o linkLink copiado para a área de transferência!
The Resource Operator itself does not do anything until the user creates an object. As soon as the user creates an AutomationControllerProject or AnsibleJob resource, the Resource Operator starts processing that object.
Prerequisites
- Install the Kubernetes-based cluster of your choice.
-
Deploy automation controller using the
automation-controller-operator
.
Next steps
After installing the automation-controller-resource-operator
in your cluster, you must create a Kubernetes (k8s) secret with the connection information for your automation controller instance. Then you can use Resource Operator to create a k8s resource to manage your automation controller instance.
12.3. Connecting Resource Operator to platform gateway Copiar o linkLink copiado para a área de transferência!
To connect Resource Operator with platform gateway you must create a Kubernetes secret with the connection information for your automation controller instance.
Use the following procedure to create an OAuth2 token for your user in the platform gateway UI.
You can only create OAuth 2 Tokens for your own user through the API or UI, which means you can only configure or view tokens from your own user profile.
Procedure
- Log in to Red Hat OpenShift Container Platform.
-
In the navigation panel, select
. - Select the username you want to create a token for.
-
Select
- Click .
You can leave Applications empty. Add a description and select Read or Write for the Scope.
NoteMake sure you provide a valid user when creating tokens. Otherwise, you get an error message that you tried to issue the command without either specifying a user, or supplying a username that does not exist.
12.4. Creating a automation controller connection secret for Resource Operator Copiar o linkLink copiado para a área de transferência!
To make your connection information available to the Resource Operator, create a k8s secret with the token and host value.
Procedure
The following is an example of the YAML for the connection secret. Save the following example to a file, for example,
automation-controller-connection-secret.yml
.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Edit the file with your host and token value.
-
Apply it to your cluster by running the
kubectl create
command:
kubectl create -f controller-connection-secret.yml
kubectl create -f controller-connection-secret.yml
12.5. Creating custom resources for Resource Operator Copiar o linkLink copiado para a área de transferência!
Use the Resource Operator to manage automation controller resources directly from your Kubernetes cluster. This section provides the procedures for creating custom resources like AnsibleJob, JobTemplate, AnsibleProject, and more.
12.5.1. Creating an AnsibleJob custom resource Copiar o linkLink copiado para a área de transferência!
An AnsibleJob custom resource launches a job in the automation controller instance specified in the Kubernetes secret (automation controller host URL, token). You can launch an automation job on automation controller by creating an AnsibleJob resource.
Procedure
Specify the connection secret and job template you want to launch.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure features such as, inventory, extra variables, and time to live for the job.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteYou must enable prompt on launch for inventories and extra variables if you are configuring those. To enable Prompt on launch, within the automation controller UI: From the
page, select your template and select the Prompt on launch checkbox next to Inventory and Variables sections. Launch a workflow job template with an AnsibleJob object by specifying the
workflow_template_name
instead ofjob_template_name
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.2. Creating a JobTemplate custom resource Copiar o linkLink copiado para a área de transferência!
A job template is a definition and set of parameters for running an Ansible job. For more information see the Job Templates section of the Using automation execution guide.
Procedure
Create a job template on automation controller by creating a JobTemplate custom resource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.3. Creating an automation controller project custom resource Copiar o linkLink copiado para a área de transferência!
A Project is a logical collection of Ansible playbooks, represented in automation controller. For more information see the Projects section of the Using automation execution guide.
Procedure
Create a project on automation controller by creating an automation controller project custom resource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.4. Creating an automation controller schedule custom resource Copiar o linkLink copiado para a área de transferência!
Define an AnsibleSchedule
custom resource to create a schedule on the automation controller, ensuring you specify the necessary apiVersion
, kind
, and a unique metadata.name
.
Procedure
Create a schedule on automation controller by creating an automation controller schedule custom resource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.5. Creating an automation controller workflow custom resource Copiar o linkLink copiado para a área de transferência!
Workflows enable you to configure a sequence of disparate job templates (or workflow templates) that may or may not share inventory, playbooks, or permissions. For more information see the Workflows in automation controller section of the Using automation execution guide.
Procedure
Create a workflow on automation controller by creating a workflow custom resource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.6. Creating an automation controller workflow template custom resource Copiar o linkLink copiado para a área de transferência!
A workflow job template links together a sequence of disparate resources to track the full set of jobs that were part of the release process as a single unit.
For more information see the Workflow job templates section of the Using automation execution guide.
Procedure
Create a workflow template on automation controller by creating a workflow template custom resource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.7. Creating an automation controller inventory custom resource Copiar o linkLink copiado para a área de transferência!
By using an inventory file, Ansible Automation Platform can manage a large number of hosts with a single command.
Inventories also help you use Ansible Automation Platform more efficiently by reducing the number of command line options you have to specify. For more information see the Inventories section of the Using automation execution guide.
Procedure
Create an inventory on automation controller by creating an inventory custom resource:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
12.5.8. Creating an automation controller credential custom resource Copiar o linkLink copiado para a área de transferência!
Credentials authenticate the automation controller user when launching jobs against machines, synchronizing with inventory sources, and importing project content from a version control system.
SSH and AWS are the most commonly used credentials. For a full list of supported credentials see the Credential types section of the Using automation execution guide.
For help with defining values you can refer to the OpenAPI (Swagger) file for Red Hat Ansible Automation Platform API KCS article.
You can use https://<aap-instance>/api/controller/v2/credential_types/
to view the list of credential types on your instance. To get the full list use the following curl
command:
export AAP_TOKEN="your-oauth2-token" export AAP_URL="https://your-aap-controller.example.com" curl -s -H "Authorization: Bearer $AAP_TOKEN" "$AAP_URL/api/controller/v2/credential_types/" | jq -r '.results[].name'
export AAP_TOKEN="your-oauth2-token"
export AAP_URL="https://your-aap-controller.example.com"
curl -s -H "Authorization: Bearer $AAP_TOKEN" "$AAP_URL/api/controller/v2/credential_types/" | jq -r '.results[].name'
Procedure
Create an AWS or SSH credential on automation controller by creating a credential custom resource:
SSH credential:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow AWS credential:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow