0

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?

U880D
  • 1,017
  • 2
  • 12
  • 18

1 Answers1

1

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)

U880D
  • 1,017
  • 2
  • 12
  • 18