diff --git a/support/awx/README.md b/support/awx/README.md new file mode 100644 index 0000000..e2532b6 --- /dev/null +++ b/support/awx/README.md @@ -0,0 +1,42 @@ +# Using this Ansible role from AWX / Ansible Tower + +Install the Tower CLI: + +```sh +sudo yum install python2-ansible-tower-cli +``` + +Review the [tower-assets.yaml](tower-assets.yaml) and adjust it to match your environment. +Search for those placeholders to replace: + +- YOUR_ACCESS_TOKEN +- CLIENT_ID +- CLIENT_SECRET +- SSO_HOST +- REALM +- TENANT + +Use the tower-cli to create the resources in Tower: + +```sh +tower-cli send -h ansible.app.itix.fr -u admin -p secret support/awx/tower-assets.yaml +``` + +You can now provision an API from your favourite CI/CD tool. For example, from Jenkins you could use: + +```groovy +def towerExtraVars = [ + git_repo: "https://github.com/nmasse-itix/rhte-api.git", + git_branch: "master", + openapi_file: "openapi-spec.yaml", + threescale_cicd_api_base_system_name: "event_api", + threescale_cicd_private_base_url: "https://echo-api.3scale.net", + threescale_cicd_api_environment_name: "prod", + threescale_cicd_wildcard_domain: "prod.app.openshift.test" +] + +ansibleTower towerServer: "tower", + inventory: "3scale", + jobTemplate: "Deploy an API to 3scale", + extraVars: JsonOutput.toJson(towerExtraVars) +``` diff --git a/support/awx/deploy-api.yml b/support/awx/deploy-api.yml index 4531f2b..95e93d5 100644 --- a/support/awx/deploy-api.yml +++ b/support/awx/deploy-api.yml @@ -1,6 +1,6 @@ --- -- name: Deploy an API to a 3scale SaaS instance, with self-managed APIcasts +- name: Deploy an API to 3scale hosts: threescale gather_facts: no pre_tasks: diff --git a/support/awx/tower-assets.yaml b/support/awx/tower-assets.yaml new file mode 100644 index 0000000..25fee17 --- /dev/null +++ b/support/awx/tower-assets.yaml @@ -0,0 +1,85 @@ +- ask_variables_on_launch: true + asset_relation: + extra_credentials: [] + notification_templates_error: [] + notification_templates_success: [] + roles: + - name: Read + team: [] + user: [] + - name: Execute + team: [] + user: [] + - name: Admin + team: [] + user: [] + schedules: [] + survey_spec: {} + asset_type: job_template + name: Deploy an API to 3scale + playbook: support/awx/deploy-api.yml + inventory: 3scale + project: Deploy API to 3scale + verbosity: 1 +- asset_relation: + notification_templates_error: [] + notification_templates_success: [] + roles: + - name: Admin + team: [] + user: [] + - name: Read + team: [] + user: [] + - name: Use + team: [] + user: [] + - name: Update + team: [] + user: [] + schedules: [] + asset_type: project + description: Enable continuous deployment of an API to 3scale AMP + name: Deploy API to 3scale + organization: Default + scm_branch: master + scm_type: git + scm_update_cache_timeout: 60 + scm_update_on_launch: true + scm_url: https://github.com/nmasse-itix/threescale-cicd.git +- asset_relation: + group: + - hosts: + - TENANT-admin.3scale.net + name: threescale + sub_groups: [] + variables: '--- + + threescale_cicd_access_token: YOUR_ACCESS_TOKEN + + threescale_cicd_sso_issuer_endpoint: https://CLIENT_ID:CLIENT_SECRET@SSO_HOST/auth/realms/REALM' + host: + - name: TENANT-admin.3scale.net + inventory_source: [] + roles: + - name: Ad Hoc + team: [] + user: [] + - name: Admin + team: [] + user: [] + - name: Read + team: [] + user: [] + - name: Use + team: [] + user: [] + - name: Update + team: [] + user: [] + asset_type: inventory + name: 3scale + organization: Default + variables: '--- + + ansible_connection: local' diff --git a/support/jenkins/Jenkinsfile b/support/jenkins/Jenkinsfile index 7cbd231..b7c1b86 100644 --- a/support/jenkins/Jenkinsfile +++ b/support/jenkins/Jenkinsfile @@ -4,6 +4,7 @@ * This Jenkins Pipeline depends on the following plugins : * - Credentials Binding (https://plugins.jenkins.io/credentials-binding) * - Ansible (https://plugins.jenkins.io/ansible) + * - Ansi Color (https://plugins.jenkins.io/ansicolor) */ pipeline { diff --git a/support/jenkins/README.md b/support/jenkins/README.md index bc481b7..a8b2fd4 100644 --- a/support/jenkins/README.md +++ b/support/jenkins/README.md @@ -37,6 +37,8 @@ oc logs -f bc/jenkins-ansible-slave - Go to the **Available** tab - In the **Filter** text field, type `Ansible` - In the list, find the **Ansible plugin** and check its box in the **Enabled** column +- In the **Filter** text field, type `Ansi Color` +- In the list, find the **Ansi Color** and check its box in the **Enabled** column - Click **Install without restart** ## Create the pipeline that calls Ansible