Code Monkey home page Code Monkey logo

Comments (8)

guenhter avatar guenhter commented on June 11, 2024

This was introduced with #254

from ansible-gitlab-runner.

guenhter avatar guenhter commented on June 11, 2024

What version of ansible do you use?

from ansible-gitlab-runner.

kakawait avatar kakawait commented on June 11, 2024

What version of ansible do you use?

I'm using

ansible [core 2.12.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.8/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.8.12 (default, Sep 16 2021, 10:46:05) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 2.10.3
  libyaml = True

To be honest just used pre-packaged (dnf) version, but I could upgrade if required more recent version

from ansible-gitlab-runner.

guenhter avatar guenhter commented on June 11, 2024

Can you run this two tasks to see if they pass on your system? (this is I think the issue on your end but I'm not 100% certain so that experiment would be helpful).

    - file:
        path: /tmp/foo1
        state: touch
    - blockinfile:
        dest: "/tmp/foo1"
        content: "{{ lookup('template', 'config.runners.docker.services.j2') if nondefinedvariable is defined }}"
        state: "{{ 'present' if nondefinedvariable is defined else 'absent' }}"
        marker: "# {mark} runners.docker.services"
        insertafter: EOF
      check_mode: no

from ansible-gitlab-runner.

kakawait avatar kakawait commented on June 11, 2024

Can you run this two tasks to see if they pass on your system? (this is I think the issue on your end but I'm not 100% certain so that experiment would be helpful).

    - file:
        path: /tmp/foo1
        state: touch
    - blockinfile:
        dest: "/tmp/foo1"
        content: "{{ lookup('template', 'config.runners.docker.services.j2') if nondefinedvariable is defined }}"
        state: "{{ 'present' if nondefinedvariable is defined else 'absent' }}"
        marker: "# {mark} runners.docker.services"
        insertafter: EOF
      check_mode: no

Same issue

# ansible-playbook --connection=local --inventory inventory.yml t.yml

PLAY [runner] *********************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ************************************************************************************************************************************************************************************************************************
ok: [gitlab.blabla]

TASK [file] ***********************************************************************************************************************************************************************************************************************************
changed: [gitlab.blabla]

TASK [blockinfile] ****************************************************************************************************************************************************************************************************************************
fatal: [gitlab.blabla]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: the inline if-expression on line 1 evaluated to false and no else section was defined.\n\nThe error appears to be in '/tmp/gitlab-ansible-playbook/t.yml': line 6, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n        state: touch\n    - blockinfile:\n      ^ here\n"}

PLAY RECAP ************************************************************************************************************************************************************************************************************************************
gitlab.blabla       : ok=2    changed=1    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   

# cat t.yml
- hosts: runner
  tasks:
    - file:
        path: /tmp/foo1
        state: touch
    - blockinfile:
        dest: "/tmp/foo1"
        content: "{{ lookup('template', 'config.runners.docker.services.j2') if nondefinedvariable is defined }}"
        state: "{{ 'present' if nondefinedvariable is defined else 'absent' }}"
        marker: "# {mark} runners.docker.services"
        insertafter: EOF
      check_mode: no

from ansible-gitlab-runner.

guenhter avatar guenhter commented on June 11, 2024

Alright, then I'm pretty certain that you issue is the Ansible/jinja version.
I run this experiment with

ansible [core 2.12.2]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True

and there it works.

Maybe you can upgrade and see if it works.

from ansible-gitlab-runner.

kakawait avatar kakawait commented on June 11, 2024

Alright, then I'm pretty certain that you issue is the Ansible/jinja version. I run this experiment with

ansible [core 2.12.2]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True

and there it works.

Maybe you can upgrade and see if it works.

Yes I think high chance related to jinja version but I've to check how to upgrade because seems to be embedded with ansible because my pip3 show jinja2 does not return the same version.

I'll keep you in touch. But I think we can already close the issue if is related to old version of jinja

from ansible-gitlab-runner.

guenhter avatar guenhter commented on June 11, 2024

I will close this for the moment because it seems to be a version issue. Feel free to reopen it in case I'm wrong.

from ansible-gitlab-runner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.