Additionally, you're looping over package_names. I think you may need to instead pull this out to another task_list and include_tasks while looping instead.
On Fri, Aug 12, 2022 at 9:35 AM Paul Manno <[email protected]> wrote: > You need to move this out of the block > - name: "Verificamos si el paquete esta instalado" > shell: > cmd: | > rpm -q "{{ item }}" > with_items: "{{ package_names }}" > register: package_check > > On Fri, Aug 12, 2022 at 9:29 AM SysAdmin EM <[email protected]> wrote: > >> Hi, i create a playbook to remove a yum package: >> >> --- >> - name: "Eliminamos dnsmasq y agregamos dns del endpoint de route53" >> hosts: servers >> vars: >> package_names: >> - dnsmasq >> become: yes >> gather_facts: no >> tasks: >> - block: >> - name: "Verificamos si el paquete esta instalado" >> shell: >> cmd: | >> rpm -q "{{ item }}" >> with_items: "{{ package_names }}" >> register: package_check >> - name: "Borramos el paquete" >> yum: >> name: "{{ item }}" >> state: absent >> - name: "Agregamos IPs de los nuevos DNS de route53" >> lineinfile: >> path: /etc/resolv.conf >> backup: yes >> state: present >> line: "{{ item }}" >> with_items: >> - 'nameserver 10.54.130.237' >> - 'nameserver 10.54.131.106' >> - 'nameserver 169.254.169.253' >> - name: "Comentamos el primer nameserver ya que no usamos mas" >> shell: >> cmd: | >> sed -i '/nameserver/{s/.*/#&/;:A;n;bA}' /etc/resolv.conf >> when: package_check is succeeded >> >> i see this error: >> >> FAILED! => {"msg": "The conditional check 'package_check is succeeded' >> failed. The error was: The 'failed' test expects a dictionary\n\nThe error >> appears to be in '/etc/ansible/mod_replace/playbook/comment_inser.yaml': >> line 11, column 11, but may\nbe elsewhere in the file depending on the >> exact syntax problem.\n\nThe offending line appears to be:\n\n - >> block:\n - name: \"Verificamos si el paquete esta instalado\"\n >> ^ here\n"} >> >> any helps? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ansible Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/CAGUDtnmnbfGuOjgUbTqm3Oa358Z%2B1htBoE6HyyEj2uB8yHXhmw%40mail.gmail.com >> <https://groups.google.com/d/msgid/ansible-project/CAGUDtnmnbfGuOjgUbTqm3Oa358Z%2B1htBoE6HyyEj2uB8yHXhmw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAHN57wq%2B-KVGzNcdtvJ_xq-hZPmyUaNL5eYabwJwL4-mJhKo3g%40mail.gmail.com.
