Score:0

How to replace shell module with command module in Ansible?

ne flag

I need one small help.

In below example I need to replace shell with command module. But I am confused as command is not working with pipe.

So please give me the solution of this task. E.g:

- name: Get the version
  become: true
  run_once: true
  shell: zypper pa | grep eric-odl | awk -F {'print $4'}
  register: odl_version

How I will split this task because each command output is dependent on next command?

Score:1
ca flag

I need to replace shell with command module.

Maybe you can provide more background information about the why and what you try to achieve.

Currently I guess according man zypper you try to

packages (pa) [options] [repository]...

List all available packages or all packages from specified repositories. Similar to zypper search -s -t package.

first and like to proceed further with something afterwards.


But I am confused command is not working with pipe.

Right, that is the case and the intended behavior. See in example


So please give me the solution of this task

There will be not "that solution" but you may have a look into the following list from most to least preferable approaches:

Or, at least, just stay with shell for commands with pipes (and your given example as it is currently)

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.