On Tue, Sep 26, 2023 at 6:17 PM 'Matt Zagrabelny' via Ansible Project < [email protected]> wrote:
> Here are the two tasks: > > - > name: get editor realpath > shell: realpath /usr/bin/editor > Use `command` here instead of `shell` > register: editor_realpath > changed_when: False > tags: > - vim > > - > name: set editor to vim > command: update-alternatives --set editor /usr/bin/vim.nox > when: editor_realpath.stdout != '/usr/bin/vim.nox' > tags: > - vim > > I guess I'd like the "set editor to vim" task to be "OK" if it is already > set to vim, but it is showing up as "skipped". > Not sure how to do that > > Any thoughts? > > -m > > On Tue, Sep 26, 2023 at 7:00 PM Richard Megginson <[email protected]> > wrote: > >> Check the `when:` condition on the skipped task. Why is the condition >> `false`? >> >> On Tue, Sep 26, 2023 at 5:09 PM 'Matt Zagrabelny' via Ansible Project < >> [email protected]> wrote: >> >>> Thanks for the help Richard! >>> >>> Any ideas on changing "skipped" to "ok": >>> >>> [...] >>> >>> TASK [common : set editor to vim] >>> ************************************************************************************************************************************************************ >>> skipping: [zed] >>> >>> [...] >>> >>> PLAY RECAP >>> *********************************************************************************************************************************************************************************** >>> zed : ok=23 changed=0 unreachable=0 >>> failed=0 skipped=1 rescued=0 ignored=0 >>> >>> Again, thank you for the great assistance. >>> >>> Cheers, >>> >>> -m >>> >>> On Tue, Sep 26, 2023 at 4:30 PM Richard Megginson <[email protected]> >>> wrote: >>> >>>> Sounds like you need to use `changed_when: false` here - >>>> https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_error_handling.html#defining-changed >>>> >>>> On Tue, Sep 26, 2023 at 3:09 PM 'Matt Zagrabelny' via Ansible Project < >>>> [email protected]> wrote: >>>> >>>>> Greetings, >>>>> >>>>> I currently register some variables via: >>>>> >>>>> cat roles/configure_account_environment/tasks/main.yaml >>>>> --- >>>>> # This playbook contains plays that will be run to configure an >>>>> account. >>>>> >>>>> - >>>>> name: get {{ primary_user }} account's home directory >>>>> shell: getent passwd {{ primary_user }} | cut -d ":" -f 6 >>>>> register: home_directory >>>>> >>>>> ...and when I run the playbook I get: >>>>> >>>>> [...] >>>>> TASK [configure_account_environment : get root account's home >>>>> directory] ********************* >>>>> changed: [zed] >>>>> >>>>> PLAY RECAP >>>>> *********************************************************************************** >>>>> zed : ok=23 changed=2 unreachable=0 >>>>> failed=0 skipped=1 rescued=0 ignored=0 >>>>> [...] >>>>> >>>>> Having variables that get registered show up as "changed" feels >>>>> misleading to me. Nothing is "changing" on the target node, I'm just >>>>> getting some information from that system. >>>>> >>>>> Is there a way to mark registered variables as something other than >>>>> "changed" in the output of the playbook run? >>>>> >>>>> Thanks for any hints and help! >>>>> >>>>> -m >>>>> >>>>> -- >>>>> 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/CAOLfK3VTp8dU%3DzBhL%3Dy%3DSuF1ZcQ5wh3gVPEK3xNMc24yvG4kKg%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/ansible-project/CAOLfK3VTp8dU%3DzBhL%3Dy%3DSuF1ZcQ5wh3gVPEK3xNMc24yvG4kKg%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/CALF5A-JHVF9_tTRWA71zGOe552VuEpDaJrY55PuOfxK8BH0Pyg%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/ansible-project/CALF5A-JHVF9_tTRWA71zGOe552VuEpDaJrY55PuOfxK8BH0Pyg%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/CAOLfK3VF0MJE1zF-3OOrhDkSxfQGsj9ORbiu%2BTGVj6mJgB%3DX9w%40mail.gmail.com >>> <https://groups.google.com/d/msgid/ansible-project/CAOLfK3VF0MJE1zF-3OOrhDkSxfQGsj9ORbiu%2BTGVj6mJgB%3DX9w%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/CALF5A-LM62C_pQYhkhjT6g20fiXqZJH1qJzos0Odyjk4mCxXSw%40mail.gmail.com >> <https://groups.google.com/d/msgid/ansible-project/CALF5A-LM62C_pQYhkhjT6g20fiXqZJH1qJzos0Odyjk4mCxXSw%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/CAOLfK3WVPOjT2nV5vs1X9bOq5oPcowYtR2MdDbUk%3Dj%3D1xXW2kQ%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAOLfK3WVPOjT2nV5vs1X9bOq5oPcowYtR2MdDbUk%3Dj%3D1xXW2kQ%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/CALF5A-K5L7sxmzORWXOLYrKQt6B9Xdb7m3X_abD7NcaeiMr4YQ%40mail.gmail.com.
