Skip to content

Latest commit

 

History

History
123 lines (95 loc) · 3.99 KB

File metadata and controls

123 lines (95 loc) · 3.99 KB

ocp-workload-developer-environment - Sample Config

Role overview

  • This is a simple role that does the following:

    • Playbook: pre_workload.yml - Sets up an environment for the workload deployment

      • Adds a user to a list of groups defined in the defaults file.

      • Sets a cluster resource quota for the user based on the variables in the defaults file .

      • Debug task will print out: pre_workload Tasks Complete

    • Playbook: workload.yml - Used to deploy the actual workload, i.e, 3scale, Mobile or some Demo

      • This role doesn’t do anything here

      • Debug task will print out: workload Tasks Complete

    • Playbook: post_workload.yml - Used to configure the workload after deployment

      • This role doesn’t do anything here

      • Debug task will print out: post_workload Tasks Complete

Set up your Ansible inventory file

  • You will need to create an Ansible inventory file to define your connection method to your host (Master/Bastion with OC command)

  • You can also use the command line to define the hosts directly if your ssh configuration is set to connect to the host correctly

  • You can also use the command line to use localhost or if your cluster is already authenticated and configured in your oc configuration

example inventory file
[gptehosts:vars]
ansible_ssh_private_key_file=~/.ssh/keytoyourhost.pem
ansible_user=ec2-user

[gptehosts:children]
openshift

[openshift]
bastion.cluster1.openshift.opentlc.com
bastion.cluster2.openshift.opentlc.com
bastion.cluster3.openshift.opentlc.com ansible_ssh_host=ec2-11-111-111-11.us-west-2.compute.amazonaws.com
bastion.cluster4.openshift.opentlc.com


[dev]
bastion.cluster1.openshift.opentlc.com
bastion.cluster2.openshift.opentlc.com


[prod]
bastion.cluster3.openshift.opentlc.com
bastion.cluster4.openshift.opentlc.com

Review the defaults variable file

  • This file ./defaults/main.yml contains all the variables you need to define to control the deployment of your workload.

  • You can modify any of these default values by adding -e"variable_name=variable_value" to the command line

Deploy Workload on OpenShift Cluster from an existing playbook:

- name: Deploy a workload role on a master host
  hosts: all
  become: true
  gather_facts: False
  tags:
    - step007
  roles:
    - { role: "{{ocp_workload}}", when: 'ocp_workload is defined' }
Note
You might want to change hosts: all to fit your requirements

Deploy a Workload with the ocp-workload playbook [Mostly for testing]

TARGET_HOST="bastion.dev311.openshift.opentlc.com"
OCP_USERNAME="hguerrer-redhat.com"
WORKLOAD="ocp-workload-3scale-demo"
GUID=0418

# a TARGET_HOST is specified in the command line, without using an inventory file
ansible-playbook -i ${TARGET_HOST}, ./configs/ocp-workloads/ocp-workload.yml \
                 -e"ansible_ssh_private_key_file=~/.ssh/id_rsa" \
                 -e"ansible_user=opentlc-mgr" \
                    -e"ocp_username=${OCP_USERNAME}" \
                    -e"ocp_workload=${WORKLOAD}" \
                    -e"guid=${GUID}" \
                    -e"ocp_user_needs_quota=true" \
                    -e"ocp_apps_domain=apps.dev311.openshift.opentlc.com" \
                    -e"ACTION=create"

To Delete an environment

TARGET_HOST="bastion.dev311.openshift.opentlc.com"
OCP_USERNAME="hguerrer-redhat.com"
WORKLOAD="ocp-workload-3scale-demo"
GUID=0418

# a TARGET_HOST is specified in the command line, without using an inventory file
ansible-playbook -i ${TARGET_HOST}, ./configs/ocp-workloads/ocp-workload.yml \
                 -e"ansible_ssh_private_key_file=~/.ssh/id_rsa" \
                    -e"ansible_user=opentlc-mgr" \
                    -e"ocp_username=${OCP_USERNAME}" \
                    -e"ocp_workload=${WORKLOAD}" \
                    -e"guid=${GUID}" \
                    -e"ACTION=remove"