You may try to gather fact, register the fact then execute the command in
the next task. For me i usually  use shell to query what i need before
proceeding next step, save a bit of time.

--- Example:
---
- name: Set location
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
  - name: Output disk information
    shell: fdisk -l /dev/sda | grep '^/dev' | cut -d' ' -f1
    register: myoutput
  - name: install
    shell: echo "{{myoutput.stdout_lines}}"





Vào Th 2, 23 thg 10, 2023 vào lúc 18:14 Kathy L <[email protected]> đã
viết:

> We are trying to update packages on several AWS servers via ansible. In
> the beginning of our playbook we have the environment to noninteractive
> like this:
>     environment:
>        DEBIAN_FRONTEND: noninteractive
>
> When I run an update (or try to install anything, I get the error stating
> "/dev/sda does not exist". That is because for example, when provisioning
> AWS nodes, the disk type is not /dev/sda but something else.
>
> My question is how do i run update grub-pc with a specific disk?  I'm
> assuming I would get the disk "name" from ansible_facts (devices), grab the
> first disk, then run something similar to  "apt install grub-pc /dev/nvme01"
>
> Is there a way to do this?  I tried the line above and it failed and I'm
> out of ideas.
>
> --
> 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/2d19e75c-e914-48ce-af23-7d5ec79c2872n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/2d19e75c-e914-48ce-af23-7d5ec79c2872n%40googlegroups.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/CA%2BnV635dwsmrtjGWE0bwSDmaq4_0a0A3GXS1oM2XikYJ03823A%40mail.gmail.com.

Reply via email to