ipspace / netlab

Making virtual networking labs suck less
https://netlab.tools
Other
403 stars 56 forks source link

[BUG] custom config is not rendered with "netlab initial -o" if it is located on a subdirectory #1207

Closed ssasso closed 1 month ago

ssasso commented 1 month ago

In https://github.com/ipspace/netlab/blob/fb1bd7928e410e2d9dd071996b5a487d1c969da7/netsim/ansible/tasks/create-custom-config.yml#L21

if the custom config is on a subdirectory, the template actions fails.

Topology example:

provider: clab

defaults.device: vyos

nodes:
  igw01:
    config: [ "extra/igw01.j2" ]

links:
- igw01:

Significative output (with ansible -vvv)

TASK [template] ******************************************************************************************************************************************************************************************************************
task path: /root/GIT_H/netlab/netsim/ansible/tasks/create-custom-config.yml:19
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472 `" && echo ansible-tmp-1717409037.486733-22680-163627915750472="` echo /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472 `" ) && sleep 0'
Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/stat.py
<localhost> PUT /root/.ansible/tmp/ansible-local-22588dlne0_d7/tmpq66f9oz0 TO /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/AnsiballZ_stat.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/ /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/AnsiballZ_stat.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/AnsiballZ_stat.py && sleep 0'
<localhost> PUT /root/.ansible/tmp/ansible-local-22588dlne0_d7/tmpvnl30dwf/igw01.j2 TO /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/source
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/ /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/source && sleep 0'
Using module file /usr/local/lib/python3.8/dist-packages/ansible/modules/copy.py
<localhost> PUT /root/.ansible/tmp/ansible-local-22588dlne0_d7/tmpkxe0ahm2 TO /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/AnsiballZ_copy.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/ /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/AnsiballZ_copy.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/AnsiballZ_copy.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/ > /dev/null 2>&1 && sleep 0'
fatal: [igw01 -> localhost]: FAILED! => changed=false
  checksum: cf5e50f4cf4ce5a1c3fdf116a3dcf0c6af02065a
  diff: []
  invocation:
    module_args:
      _original_basename: igw01.j2
      attributes: null
      backup: false
      checksum: cf5e50f4cf4ce5a1c3fdf116a3dcf0c6af02065a
      content: null
      dest: /root/TOPOLOGIES/bugs/bug1206/config/igw01.extra/igw01.j2.cfg
      directory_mode: null
      follow: false
      force: true
      group: null
      local_follow: null
      mode: null
      owner: null
      remote_src: null
      selevel: null
      serole: null
      setype: null
      seuser: null
      src: /root/.ansible/tmp/ansible-tmp-1717409037.486733-22680-163627915750472/source
      unsafe_writes: false
      validate: null
  msg: Destination directory /root/TOPOLOGIES/bugs/bug1206/config/igw01.extra does not exist

Will try to address this together with #1206 .