Re: ansibe-fehler undefined variable...

Forside
Vedhæftede filer:
Indlæg som e-mail
+ (text/plain)
Slet denne besked
Besvar denne besked
Skribent: Sebastian Harl
Dato:  
Til: list, Norman Zimmer
Emne: Re: ansibe-fehler undefined variable...
LMGTFY: https://www.reddit.com/r/ansible/comments/7pq3y1/include_variable_in_lineinfile/

Ich hab keine Ahnung von Ansible aber offenbar kann die Variable nur in Templates verwendet werden.

On 14 July 2023 07:00:20 UTC, Norman Zimmer <mail@???> wrote:
>Hi,
>
>ich hab hier eine lustige Fehlermeldung in Ansible.
>Die Variable "{{ ansible_managed }}" wird von mir an mehreren Stellen verwendet.
>
>Variante 1: In Template-Files, hier wird die Variable wie erwartet verwendet.
>
>bigboss@frodo3th:/etc/ansible/roles/vim/templates/etc/vim$ head -n 4 vimrc.local.j2
>"
>" {{ ansible_managed }}
>" vimrc.local 2023-07-14
>"
>
>root@newserver:/etc/vim# head -n 4 vimrc.local
>"
>" Ansible managed
>" vimrc.local 2023-07-14
>"
>
>Variante 2: In Task-Files, hier gibts eine Fehlemeldung.
>
>bigboss@frodo3th:/etc/ansible/roles/nagios-nrpe-server/tasks$ vi main.yml
> 20 - name: Edit nrpe.cfg File, Ansible Managed
> 21 lineinfile:
> 22 name: '/etc/nagios/nrpe.cfg'
> 23 line: "# {{ ansible_managed }}"
> 24 create: yes
> 25 insertbefore: BOF
> 26 state: present
> 27 notify: restart nagios-nrpe-server
>
>TASK [nagios-nrpe-server : Edit nrpe.cfg File, Ansible Managed] **********************************************************************************************
>fatal: [newserver]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'ansible_managed' is undefined\n\nThe error appears to be in '/etc/ansible/roles/nagios-nrpe-server/tasks/main.yml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Edit nrpe.cfg File, Ansible Managed\n ^ here\n"}
>
>... any Ideas?
>
>LG Norman
>
>


-- 
Sent from my phone. Please excuse my brevity.
--
Mailing-Liste der Linux User Schwabach (LUSC) e.V.
Vor und beim Posten bitte
        ?http://lusc.de/List-Netiquette <   und
        ?http://lusc.de/List-Howto      <   beachten. Danke!