ansible/configs/ansible-skylight/env_vars.yml | ●●●●● patch | view | raw | blame | history | |
ansible/configs/ansible-skylight/post_software.yml | ●●●●● patch | view | raw | blame | history | |
ansible/configs/ansible-skylight/workloads.yml | ●●●●● patch | view | raw | blame | history | |
ansible/roles/agnosticd-workload/defaults/main.yml | ●●●●● patch | view | raw | blame | history | |
ansible/roles/agnosticd-workload/readme.adoc | ●●●●● patch | view | raw | blame | history | |
ansible/roles/agnosticd-workload/tasks/main.yml | ●●●●● patch | view | raw | blame | history | |
ansible/roles/agnosticd-workload/tasks/post_workload.yml | ●●●●● patch | view | raw | blame | history | |
ansible/roles/agnosticd-workload/tasks/pre_workload.yml | ●●●●● patch | view | raw | blame | history | |
ansible/roles/agnosticd-workload/tasks/remove_workload.yml | ●●●●● patch | view | raw | blame | history | |
ansible/roles/agnosticd-workload/tasks/workload.yml | ●●●●● patch | view | raw | blame | history |
ansible/configs/ansible-skylight/env_vars.yml
@@ -2,8 +2,16 @@ ###### VARIABLES YOU SHOULD CONFIGURE FOR YOUR DEPLOYEMNT ###### OR PASS as "-e" args to ansible-playbook command ### Common Host settings ## Indicate the list of private workloads to deploy with # this config. Takes a list of remote workloads as parameter # private_workloads: # - name: workload-name # url: ssh://github.com:foo/bar.git # path: /classroom/infrastructure/agnosticd-workload # ssh_key: /home/provisioner/github-private.key private_workloads: [] ### Common Host settings repo_method: file # Other Options are: file, satellite and rhn #If using repo_method: satellite, you must set these values as well. # satellite_url: satellite.example.com ansible/configs/ansible-skylight/post_software.yml
@@ -53,6 +53,9 @@ - debug: msg: "Post-Software checks completed successfully" - name: Include private workloads include_playbook: workloads.yml - name: Provisioning final tasks hosts: localhost connection: local ansible/configs/ansible-skylight/workloads.yml
New file @@ -0,0 +1,14 @@ --- - name: Install workloads hosts: bastions gather_facts: false run_once: true become: false tasks: - name: Include private workloads include_role: name: "{{ item }}" vars: ACTION: "provision" loop: "{{ private_workloads }}" ansible/roles/agnosticd-workload/defaults/main.yml
New file @@ -0,0 +1,4 @@ --- become_override: False silent: False ansible/roles/agnosticd-workload/readme.adoc
New file @@ -0,0 +1,117 @@ = ocp-workload-example - Example Workload Role == Role overview * This is a working no-op role that can be used to develop new ocp-workload roles. It consists of the following playbooks: ** Playbook: link:./tasks/pre_workload.yml[pre_workload.yml] - Sets up an environment for the workload deployment *** Debug task will print out: `pre_workload Tasks completed successfully.` ** Playbook: link:./tasks/workload.yml[workload.yml] - Used to deploy the actual workload, i.e, 3scale, Mobile or some Demo *** This role only prints the current username for which this role is provisioning. *** Debug task will print out: `workload Tasks completed successfully.` ** Playbook: link:./tasks/post_workload.yml[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 completed successfully.` ** Playbook: link:./tasks/remove_workload.yml[remove_workload.yml] - Used to delete the workload *** This role doesn't do anything here *** Debug task will print out: `remove_workload Tasks completed successfully.` == Review the defaults variable file * This file link:./defaults/main.yml[./defaults/main.yml] contains all the variables you need to define to control the deployment of your workload. * The variable *ocp_username* is mandatory to assign the workload to the correct OpenShift user. * A variable *silent=True* can be passed to suppress debug messages. * You can modify any of these default values by adding `-e "variable_name=variable_value"` to the command line === Deploy a Workload with the `ocp-workload` playbook [Mostly for testing] ---- TARGET_HOST="bastion.na39.openshift.opentlc.com" OCP_USERNAME="shacharb-redhat.com" WORKLOAD="ocp-workload-example" GUID=1001 # 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/keytoyourhost.pem" \ -e"ansible_user=ec2-user" \ -e"ocp_username=${OCP_USERNAME}" \ -e"ocp_workload=${WORKLOAD}" \ -e"silent=False" \ -e"guid=${GUID}" \ -e"ACTION=create" ---- === To Delete an environment ---- TARGET_HOST="bastion.na39.openshift.opentlc.com" OCP_USERNAME="ankay-redhat.com" WORKLOAD="ocp-workload-example" GUID=1002 # 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/keytoyourhost.pem" \ -e"ansible_user=ec2-user" \ -e"ocp_username=${OCP_USERNAME}" \ -e"ocp_workload=${WORKLOAD}" \ -e"guid=${GUID}" \ -e"ACTION=remove" ---- == Other related information: === Deploy Workload on OpenShift Cluster from an existing playbook: [source,yaml] ---- - 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 === Set up your Ansible inventory file * You can 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 [source, ini] ---- [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 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 ---- ansible/roles/agnosticd-workload/tasks/main.yml
New file @@ -0,0 +1,30 @@ --- # Do not modify this file - name: Running Pre Workload Tasks include_tasks: file: ./pre_workload.yml apply: become: "{{ become_override | bool }}" when: ACTION == "create" or ACTION == "provision" - name: Running Workload Tasks include_tasks: file: ./workload.yml apply: become: "{{ become_override | bool }}" when: ACTION == "create" or ACTION == "provision" - name: Running Post Workload Tasks include_tasks: file: ./post_workload.yml apply: become: "{{ become_override | bool }}" when: ACTION == "create" or ACTION == "provision" - name: Running Workload removal Tasks include_tasks: file: ./remove_workload.yml apply: become: "{{ become_override | bool }}" when: ACTION == "destroy" or ACTION == "remove" ansible/roles/agnosticd-workload/tasks/post_workload.yml
New file @@ -0,0 +1,24 @@ --- # Implement your Post Workload deployment tasks here # Leave these as the last tasks in the playbook # For deployment onto a dedicated cluster (as part of the # cluster deployment) set workload_shared_deployment to False # This is the default so it does not have to be set explicitely - name: pre_workload tasks complete debug: msg: "Post-Workload tasks completed successfully." when: - not silent|bool - not workload_shared_deployment|d(False) # For RHPDS deployment (onto a shared cluster) set # workload_shared_deployment to True # (in the deploy script or AgnosticV configuration) - name: pre_workload tasks complete debug: msg: "Post-Software checks completed successfully" when: - not silent|bool - workload_shared_deployment|d(False) ansible/roles/agnosticd-workload/tasks/pre_workload.yml
New file @@ -0,0 +1,24 @@ --- # Implement your Pre Workload deployment tasks here # Leave these as the last tasks in the playbook # For deployment onto a dedicated cluster (as part of the # cluster deployment) set workload_shared_deployment to False # This is the default so it does not have to be set explicitely - name: pre_workload tasks complete debug: msg: "Pre-Workload tasks completed successfully." when: - not silent|bool - not workload_shared_deployment|d(False) # For RHPDS deployment (onto a shared cluster) set # workload_shared_deployment to True # (in the deploy script or AgnosticV configuration) - name: pre_workload tasks complete debug: msg: "Pre-Software checks completed successfully" when: - not silent|bool - workload_shared_deployment|d(False) ansible/roles/agnosticd-workload/tasks/remove_workload.yml
New file @@ -0,0 +1,9 @@ --- # Implement your Workload removal tasks here # Leave this as the last task in the playbook. - name: remove_workload tasks complete debug: msg: "Remove Workload tasks completed successfully." when: not silent|bool ansible/roles/agnosticd-workload/tasks/workload.yml
New file @@ -0,0 +1,13 @@ --- # Implement your Workload deployment tasks here - name: Setting up workload for user debug: msg: "Setting up workload for user ocp_username = {{ ocp_username }}" # Leave this as the last task in the playbook. - name: workload tasks complete debug: msg: "Workload Tasks completed successfully." when: not silent|bool