ansible: using with_items with notify handler

后端 未结 4 1766
再見小時候
再見小時候 2020-12-09 18:35

I want to pass a variable to a notification handler, but can\'t find anywhere be it here on SO, the docs or the issues in the github repo, how to do it. What I\'m doing is d

4条回答
  •  有刺的猬
    2020-12-09 19:21

    I got mine to work like this - I had to add some curly brackets

    tasks:
        - name: Aktivieren von Security-, Backport- und Non-Security-Upgrades
          lineinfile:
            path: /etc/apt/apt.conf.d/50unattended-upgrades
            regexp: '^[^"//"]*"\${distro_id}:\${distro_codename}-{{ item }}";'
            line: '        "${distro_id}:${distro_codename}-{{ item }}";'
            insertafter: "Unattended-Upgrade::Allowed-Origins {"
            state: present
          register: aenderung
          loop:
            - updates
            - security
            - backports
          notify: Auskommentierte Zeilen entfernen
    
        handlers:
            - name: Auskommentierte Zeilen entfernen
              lineinfile:
                path: /etc/apt/apt.conf.d/50unattended-upgrades
                regexp: '^\/\/.*{{ item.item }}";.*'
                state: absent
              when: item.changed
              loop: "{{ aenderung.results }}"
    

提交回复
热议问题