Could someone help me out with this:
Lets say I ran a task in playbook that registers the route of the Openshift deployment.
In the next task I will check if the application is reachable and will use the uri -module.
uri:
url: "https://{{ blabla.resource[0].bla.bla }}"
What does the resource[0] indicate here?
And is the syntax correct for the variable?
If I run debug module and msg/var the register variable it shows resource as one of the attributes, but what does it mean.
If I run the whole playbook it says that the variable 0/n/n is not found or something similar.
Unfortunately I dont have the playbook nor the full example with me so I cant provide the full playbook or show the full error.
@jacuzi -
I think we would need the real playbook and error log messages to better answer this. From looking at it, I suspect it is how things are "referenced".
In the next task I will check if the application is reachable and will use the uri -module.
uri:
url: "https://{{ blabla.resource[0].bla.bla }}"
I think some of the issue here might be the URL. Only a single part of the URL would be variablized. Since you are using the "." notation here it is possible that the array (list elements) aren't being accessed properly.
I would figure out what the registered variable is, and use a debug with var to dump everything on how the contents of the variable are registered.
Then use debug with the msg to isolate the portion of the registered output you need via the "." notation or the "[]" notations.
Once you know how everything is captured and displayed, you can leverage that variable for the desired outcome. It might be possible as @Chetan_Tiwary_ suggested that it isn't in list form maybe it is a dictionary, maybe it is something else. Once you see what the registered output looks like, you can then apply filters like {{ var_out | list }} or something to get it in the correct format.
Hi @jacuzi,
I guess you tried to use the 'k8s_info' module to retrieve the information of the route resource. It returns the list of found objects as the resources key. The example below demonstrates two ways to access the application URL. The first case uses the 'openshift_route' module, and the second one uses the 'k8s_info' module.
Either way can reach out the application URL.
And the contents of the resources[0] is what you can retrieve using the 'oc get -o yaml' command.
Regards,
Toshi
Hello @jacuzi !
I will try ( but not sure what is causing this issue ).
Here, resource[0] refers to the first item in the list of resources returned by the task which is registering the route.
If you are getting the error : "variable 0/n/n is not found " this probably means that task is not returning a list of resources.
Use the debug module with msg and see what is being returned by the register task (variable ) , if it is not a list then you need to fix it as per your scenario.
Tagging @Tracy_Baker & @Travis if they can add something.
@jacuzi -
I think we would need the real playbook and error log messages to better answer this. From looking at it, I suspect it is how things are "referenced".
In the next task I will check if the application is reachable and will use the uri -module.
uri:
url: "https://{{ blabla.resource[0].bla.bla }}"
I think some of the issue here might be the URL. Only a single part of the URL would be variablized. Since you are using the "." notation here it is possible that the array (list elements) aren't being accessed properly.
I would figure out what the registered variable is, and use a debug with var to dump everything on how the contents of the variable are registered.
Then use debug with the msg to isolate the portion of the registered output you need via the "." notation or the "[]" notations.
Once you know how everything is captured and displayed, you can leverage that variable for the desired outcome. It might be possible as @Chetan_Tiwary_ suggested that it isn't in list form maybe it is a dictionary, maybe it is something else. Once you see what the registered output looks like, you can then apply filters like {{ var_out | list }} or something to get it in the correct format.
Hi @jacuzi,
I guess you tried to use the 'k8s_info' module to retrieve the information of the route resource. It returns the list of found objects as the resources key. The example below demonstrates two ways to access the application URL. The first case uses the 'openshift_route' module, and the second one uses the 'k8s_info' module.
Either way can reach out the application URL.
And the contents of the resources[0] is what you can retrieve using the 'oc get -o yaml' command.
Regards,
Toshi
Hello Jacuzi,
Are you able to provide any output from the execution of the playbook?
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.