ansible:如何执行仅安装在 delegate_to 而不是控制器上的自定义模块? 问题:问题

问题描述

我在尝试执行以下操作时遇到了(对我而言)ansible 的意外问题:

# myplaybook.ansible.yml
- hosts: myhost2

  tasks: 
  - name: Execute pgsql query
    community.postgresql.postgresql_query:
      ...

其中 myhost1 是执行 ansible-playbook -v myplaybook.ansible.yml 的控制器。 在目标主机 myhost2 上,community.postgresql.postgresql_query 安装了 ansible-galaxy install 并且依赖项(特别是 psycopg2)得到满足。

问题:

ansible 在实际评估 playbook 之前爆炸了,因为它在控制器上找不到 postgresql_query 模块,但在 myhost2 上运行它的全部目的是避免必须首先在控制器上安装此类依赖项。

同样,我也希望能够像这样执行上面的操作,这显然不是出于同样的原因:

# myplaybook.ansible.yml
- hosts: myhost3

  tasks: 
  - name: Execute pgsql query
    delegate_to: myhost2
    community.postgresql.postgresql_query:
      ...

问题

如何仅评估在目标主机或委托主机上的任务中调用的 ansible 模块?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)