I don't know what is your purpose. Is the test.j2 not in the same role?
or you don't know how to use a role?
Usually, it's just src: test.j2
About the error.
For template module with src parameter, it expects a path. But the
lookup('template'...) expands into a content.
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/template_module.html
So for what you want to do, you can use copy module and content
parameter then keep your lookup('template'...)
https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html
But I don't know why you want to do that.
On 29/11/2020 22:13, arun hotra wrote:
> I have a quick follow up question.
>
> So I am running the following task which leverages the variable.
>
> - name: Poplulate files from template
> template:
> src: "{{ lookup('template','{{ role_path }}/templates/test.j2') }}}"
> # src: "{{ lookup('template','{{ role_path
> }}/templates/bigip.j2') }}}"
> dest:
> "{{role_path}}/tmp/repos/virtualDatacenter/{{inventory_hostname_short}}.json"
>
> test.j2
>
> {
> "base": {
> "mgmt": {
> "ip":"{{ VirtualMachine_Network0_Address }}"
> },
> "dataCenter": "virtualDataCenter"
> }
> }
>
> I get an error as shown below. The host variable
> "VirtualMachine_Network0_Address" is populated - 10.254.29.109 , but
> not sure why it is ending up in this error.
>
> fatal: [
bigip1-test4.example1.com <
http://bigip1-test4.example1.com>]:
> <
gdyk...@redhat.com <mailto:
gdyk...@redhat.com>> wrote:
>
> @arun hotra <mailto:
arun...@gmail.com> Did you get it
> figured out?
>
> On Fri, Nov 27, 2020 at 11:52 AM Gerald Dykeman
> <
gdyk...@redhat.com <mailto:
gdyk...@redhat.com>> wrote:
>
> Just to clarify... the debug playbook is being run from
> Tower... correct? The variables should be accessible..
> and this does not make sense to me.
>
> On Fri, Nov 27, 2020 at 9:18 AM arun hotra
> <
arun...@gmail.com <mailto:
arun...@gmail.com>> wrote:
>
> If I remove connection: local, it attempts running on
> the host (we dont want that) and fails. Here is the
> message - it just keeps retrying this
>
> <
bigip2-test1.example1.com
> <
http://bigip2-test1.example1.com>> ssh_retry:
> attempt: 7, ssh return code is 255. cmd (['ssh',
> '-vvv', '-C', '-o', 'ControlMaster=auto', '-o',
> 'ControlPersist=1800', '-o',
> 'StrictHostKeyChecking=no', '-o',
> 'KbdInteractiveAuthentication=no', '-o',
> 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey',
> '-o', 'PasswordAuthentication=no', '-o',
> 'ConnectTimeout=1800', '-o',
> 'ControlPath=/root/.ansible/cp/03e93432ed',
> '
bigip2-test1.example1.com
> <
http://bigip2-test1.example1.com>', '/bin/sh -c
> \'echo PLATFORM; uname; echo FOUND; command -v
> \'"\'"\'/usr/bin/python\'"\'"\'; command -v
> \'"\'"\'python3.7\'"\'"\'; command -v
> \'"\'"\'python3.6\'"\'"\'; command -v
> \'"\'"\'python3.5\'"\'"\'; command -v
> \'"\'"\'python2.7\'"\'"\'; command -v
> \'"\'"\'python2.6\'"\'"\'; command -v
> \'"\'"\'/usr/libexec/platform-python\'"\'"\'; command
> -v \'"\'"\'/usr/bin/python3\'"\'"\'; command -v
> \'"\'"\'python\'"\'"\'; echo ENDFOUND && sleep
> 0\'']...), pausing for 30 seconds
>
>
> The variables are populated already as seen in the
> gui, but i can't access them, so should they be
> locally accessible ?
>
> On Thu, Nov 26, 2020 at 4:38 PM mike.charchuk
> <
mike.c...@gmail.com
> <
gdyk...@redhat.com <mailto:
gdyk...@redhat.com>>
> wrote:
>
> Can you share the project directory structure
> and print out hostvars[inventory_hostname] ?
> Also, feel free to try adding another var in
> the variables section and see if that shows up
> in debug
>
> On Thu, Nov 26, 2020 at 2:47 PM arun hotra
> <
arun...@gmail.com
> <mailto:
arun...@gmail.com>> wrote:
>
> I am not sure whether that is the issue, I
> added the three dashes but same result.
>
> This is the task I am running
>
> - name: Print a host variable
> debug:
> var: VirtualMachine_Storage_Name
>
> - name: Print a host variable inventory host
> debug:
> var: inventory_hostname
>
>
>
> TASK [buildSOT : Print a host variable]
> ********************************************************************************************************************************************************************************************************
> task path:
> /root/onboard-bigip/roles/buildSOT/tasks/populateVars.yaml:3
> Thursday 26 November 2020 13:43:17 -0600
> (0:00:00.074) 0:00:01.144 *****
> ok: [
bigip2-test1.example1.com
> <
http://bigip2-test1.example1.com>] => {
> "VirtualMachine_Storage_Name": "VARIABLE
> IS NOT DEFINED!:
> 'VirtualMachine_Storage_Name' is undefined"
> }
> ok: [
bigip1-test1.example1.com
> <
http://bigip1-test1.example1.com>] => {
> "VirtualMachine_Storage_Name": "VARIABLE
> IS NOT DEFINED!:
> 'VirtualMachine_Storage_Name' is undefined"
> }
>
> TASK [buildSOT : Print a host variable
> inventory host]
> *****************************************************************************************************************************************************************************************
> task path:
> /root/onboard-bigip/roles/buildSOT/tasks/populateVars.yaml:7
> Thursday 26 November 2020 13:43:17 -0600
> (0:00:00.069) 0:00:01.213 *****
> ok: [
bigip2-test1.example1.com
> <
http://bigip2-test1.example1.com>] => {
> "inventory_hostname":
> "
bigip2-test1.example1.com
> <
http://bigip2-test1.example1.com>"
> }
> ok: [
bigip1-test1.example1.com
> <
http://bigip1-test1.example1.com>] => {
> "inventory_hostname":
> "
bigip1-test1.example1.com
> <
http://bigip1-test1.example1.com>"
> <mailto:
awx-project...@googlegroups.com>.
> <
https://groups.google.com/d/msgid/awx-project/16612b39-25b9-4c95-9fe0-b70fd9680ae7n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are
> subscribed to the Google Groups "AWX
> Project" group.
> To unsubscribe from this group and stop
> receiving emails from it, send an email to
>
awx-project...@googlegroups.com
> <mailto:
awx-project...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/awx-project/CAN1mJZHFd5GdR4%3Dv2F%2BNVazEoMQAwYMxkDo1Z6Oj3U8RUc8n6w%40mail.gmail.com
> <
https://groups.google.com/d/msgid/awx-project/CAN1mJZHFd5GdR4%3Dv2F%2BNVazEoMQAwYMxkDo1Z6Oj3U8RUc8n6w%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>
>
> --
> GeraldDykeman, CCIE #36354
>
> Sr. Solution Architect
>
> Red Hat North America Public Sector
> <
https://www.redhat.com/>
>
>
> M:
(703)-304-2036 <tel:
(703)-304-2036>
>
> <
https://www.redhat.com/>
>
> --
> You received this message because you are subscribed
> to the Google Groups "AWX Project" group.
> To unsubscribe from this group and stop receiving
> emails from it, send an email to
>
awx-project...@googlegroups.com
> <mailto:
awx-project...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/awx-project/CAN1mJZH3ANtKaKG3AgG7MmM-M%3Da7gxQVz68Zuyocdm-T%2BQxqOA%40mail.gmail.com
> <
https://groups.google.com/d/msgid/awx-project/CAN1mJZH3ANtKaKG3AgG7MmM-M%3Da7gxQVz68Zuyocdm-T%2BQxqOA%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
>
>
> --
> GeraldDykeman, CCIE #36354
>
> Sr. Solution Architect
>
> Red Hat North America Public Sector <
https://www.redhat.com/>
>
>
> M:
(703)-304-2036 <tel:
(703)-304-2036>
>
> <
https://www.redhat.com/>
>
>
>
> --
> GeraldDykeman, CCIE #36354
>
> Sr. Solution Architect
>
> Red Hat North America Public Sector <
https://www.redhat.com/>
>
>
> M:
(703)-304-2036 <tel:
(703)-304-2036>
>
> <
https://www.redhat.com/>
>
> --
> You received this message because you are subscribed to the Google
> Groups "AWX Project" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
awx-project...@googlegroups.com
> <mailto:
awx-project...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/awx-project/CAN1mJZEjpXyDkfTnQ64T3kch97tDZ2w7qqezs07JipwLfwrCRg%40mail.gmail.com
> <
https://groups.google.com/d/msgid/awx-project/CAN1mJZEjpXyDkfTnQ64T3kch97tDZ2w7qqezs07JipwLfwrCRg%40mail.gmail.com?utm_medium=email&utm_source=footer>.