将 make 与 Ansible 一起使用时是否可以设置标志?

Is it possible to set flags when using make with Ansible?

我想知道是否可以使用其 community.general.make 模块在 ansible 中传递以下命令:

make -C safenet install PREFIX=~/.local

我是否必须按照 here 所述使用 params?例如

- name: installing safenet
  community.general.make:
    chdir: ~/myfiles/safenet
    target: install
    params:
      - "-C"
      - PREFIX=~/.local

编辑:这是我得到的输出。

TASK [Installing safenet] *******************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "argument 'params' is of type <class 'list'> and we were unable to convert to dict: <class 'list'> cannot be converted to a dict"}

如果其他人对此有疑问,这是一个相当简单的修复:您只需要使用 params 传递参数。由于此模块喜欢使用~作为主文件夹,您将需要使用变量或插件使其使用当前用户的home文件夹( $USER)。例如

- name: "Your task"
  community.general.make:
    chdir: /home/{{ lookup('env', 'USER') }}/path/to/makefile
    target: install
    params: PREFIX=/home/{{ lookup('env', 'USER') }}/path/you/want/to/use

{{ lookup('env', 'USER') }} 让 Ansible 查找当前用户名。

希望这对以后的其他人有所帮助。