Ansible Tower: Passing extra variables from one workflow template to other

30 views
Skip to first unread message

Kaliyug Antagonist

unread,
Apr 27, 2020, 9:52:27 AM4/27/20
to Ansible Project
Ansible 2.9.2
Tower 3.6.1

There are two Bitbucket repositories viz. bitbucketconfigurator and sonarconfigurator which contain playbooks to configure Bitbucket and Sonarqube projects, respectively. Here, showing just the bitbucketConfigurator:

bitbucketconfigurator-playbooks.png



In the above project, there is a **group_vars/all yaml** file as follows(note the entry bitbucket_token: "{{ PAT_admin_admin }}"):

    # Defaults used for branch access and restrictions
   
# Global vars used for rest api
    bitbucket_base_url
: 'https://git.net'
    bitbucket_rest_base_endpoint
: 'rest/api/1.0/projects'
    bitbucket_rest_url
: "{{ bitbucket_base_url }}/{{ bitbucket_rest_base_endpoint }}"
    bitbucket_branch_rest_endpoint
: "rest/branch-permissions/2.0/projects"
    bitbucket_branching_url
: "{{ bitbucket_base_url }}/rest/branch-utils/1.0/projects"
    sonar_for_bitbucket_base_endpoint
: 'rest/sonar4stash/1.0/projects'
    bitbucket_token
: "{{ PAT_admin_admin }}"
    bitbucket_rest_api_latest
: 'rest/api/latest'
    bitbucket_project_name_lc
: "{{ bitbucket.project.name  | lower }}"
    bitbucket_repository_name_lc
: "{{ bitbucket.project.repository.name  | lower }}"


The list of job templates, an example is shown further, below:

job-templates-corresponding-to-playbooks.png




As an example, let's consider the bb_configure job template I am using 'Extra Variables' to pass a yml file/dictionary e.g:

extra-vars-passed-to-job-templates.png




Here is the list of all the workflow templates, I will summarize their usage subsequently:

work-flow-templates.png




I tested the bitbucketconfigurator playbooks in a single workflow viz. wt-bitbucket. It runs successfully. Note that it uses no-arg versions of the individual playbooks i.e the config yaml file is passed to the wt-bitbucket and NOT the individual playbooks.

workflow-template-bitbucket.png




In the above workflow template, the extra vars are used:

workflow-template-extra-vars.png




Now, I am using the wk_onboarding_pipeline as a 'master' workflow template which invokes the no-arg versions of the workflow templates:

master-workflow-template.png




This 'master' template now has the config yaml file, also, note the entry PAT_admin_admin:

master-workflow-template-extra-vars.png




Issue:
When I run this 'master' template, the first playbook of the first workflow template fails as it is unable to access the 'PAT_admin_admin' passed in the extra vars.

error-master-template.png



Am I making a mistake in the invocation or have I incorrectly configured the workflow templates within a workflow template?

Kaliyug Antagonist

unread,
Apr 27, 2020, 9:54:45 AM4/27/20
to Ansible Project
In case the images seem to be a trouble, the post is duplicated on Stackoverflow.

Stefan Hornburg (Racke)

unread,
Apr 28, 2020, 3:35:04 AM4/28/20
to ansible...@googlegroups.com
On 4/27/20 3:52 PM, Kaliyug Antagonist wrote:
> *Ansible 2.9.2*
> *Tower 3.6.1*
> *

Hello Kaliyug,

Tower is not a subject of this list, only Ansible itself.

Please contact RedHat support.

Regards
Racke

> *
> There are two Bitbucket repositories viz. *bitbucketconfigurator* and *sonarconfigurator* which contain playbooks to
> configure Bitbucket and Sonarqube projects, respectively. Here, showing just the bitbucketConfigurator*:*
> *
> *
>
> bitbucketconfigurator-playbooks.png
>
>
> *
> *
> In the above project, there is a ***group_vars/all yaml** *file as follows*(note the entry bitbucket_token: "{{
> PAT_admin_admin }}"):*
> *
> *
> |
>     # Defaults used for branch access and restrictions
>     # Global vars used for rest api
>     bitbucket_base_url:'https://git.net'
>     bitbucket_rest_base_endpoint:'rest/api/1.0/projects'
>     bitbucket_rest_url:"{{ bitbucket_base_url }}/{{ bitbucket_rest_base_endpoint }}"
>     bitbucket_branch_rest_endpoint:"rest/branch-permissions/2.0/projects"
>     bitbucket_branching_url:"{{ bitbucket_base_url }}/rest/branch-utils/1.0/projects"
>     sonar_for_bitbucket_base_endpoint:'rest/sonar4stash/1.0/projects'
>     bitbucket_token:"{{ PAT_admin_admin }}"
>     bitbucket_rest_api_latest:'rest/api/latest'
>     bitbucket_project_name_lc:"{{ bitbucket.project.name  | lower }}"
>     bitbucket_repository_name_lc:"{{ bitbucket.project.repository.name  | lower }}"
> |
> *
> *
> *
> *
> The list of *job templates*, an example is shown further, below:
>
> job-templates-corresponding-to-playbooks.png
>
>
> *
> *
> *
> *
> As an example, let's consider the *bb_configure *job template I am using 'Extra Variables' to pass a yml file/dictionary
> e.g:
>
> extra-vars-passed-to-job-templates.png
>
>
> *
> *
> *
> *
> Here is the list of all the workflow templates, I will summarize their usage subsequently:
>
> work-flow-templates.png
>
>
> *
> *
> *
> *
> I tested the bitbucketconfigurator playbooks in a single workflow viz. wt-bitbucket. It runs successfully. *Note that it
> uses no-arg versions of the individual playbooks i.e the config yaml file is passed to the wt-bitbucket and NOT the
> individual playbooks.*
>
> workflow-template-bitbucket.png
>
>
> *
> *
> *
> *
> In the above workflow template, the extra vars are used:
>
> workflow-template-extra-vars.png
>
>
> *
> *
> *
> *
> Now, I am using the *wk_onboarding_pipeline as a 'master' workflow template* which invokes the no-arg versions of the
> workflow templates:
> *
> *
>
> master-workflow-template.png
>
> *
> *
> *
> *
> *
> *
> This 'master' template now has the config yaml file, also, note the entry *PAT_admin_admin:*
>
> master-workflow-template-extra-vars.png
>
>
> *
> *
> *
> *
> *Issue:*
> When I run this 'master' template, the first playbook of the first workflow template fails as it is *unable to access
> the 'PAT_admin_admin' passed in the extra vars.*
> *
> *
>
> error-master-template.png
>
>
>
> Am I making a mistake in the invocation or have I incorrectly configured the workflow templates within a workflow template?
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7e96426e-1592-4775-a3dd-5b2053e073fa%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7e96426e-1592-4775-a3dd-5b2053e073fa%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc
Reply all
Reply to author
Forward
0 new messages