我正在致力于自动化 Pritunl VPN 管理活动。我遇到了community.general.pritunl_user_info 模块。我在下面创建了一个快速测试手册。
我的问题:我不想针对主机执行此剧本(!想想!),这就是我尝试使用本地控制器的原因。该模块应该使用令牌通过 api URL 访问数据。 我如何在我的剧本中说明这一点或告诉剧本不要使用“主机”?我知道我在这里遗漏了一些东西。
感谢您的所有帮助,非常感谢!
- name: "pritunl test"
hosts: localhost
gather_facts: no
connection: local
become: no
tasks:
- name: "list pritunl users"
community.general.pritunl_user_info:
pritunl_url: https://xxxxx/
pritunl_api_token: yyyyyy
pritunl_api_secret: zzzzzz
organization: xxyyzz
上面的剧本在执行过程中被跳过/失败,因为它无法连接到本地主机。见下文。
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
redirecting (type: modules) community.general.pritunl_user_info to community.general.net_tools.pritunl.pritunl_user_info
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
PLAYBOOK: pritunl_users.yml *****************************************************************************************************************************
1 plays in pritunl_users.yml
PLAY [pritunl test] *************************************************************************************************************************************
META: ran handlers
TASK [list pritunl users] *******************************************************************************************************************************
task path: /home/.../pritunl_users.yml:8
redirecting (type: modules) community.general.pritunl_user_info to community.general.net_tools.pritunl.pritunl_user_info
redirecting (type: modules) community.general.pritunl_user_info to community.general.net_tools.pritunl.pritunl_user_info
fatal: [localhost]: FAILED! => {"changed": false, "msg": "HTTP Error 404: Not Found"}
PLAY RECAP **********************************************************************************************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
我已经复制粘贴了您的脚本并插入了值并测试了脚本。该脚本按预期工作。
我的机器上没有运行
ssh
服务器,但脚本正在运行。所以,你的问题可能也与SSH/connection to localhost
无关。
我已经能够通过更改
{"changed": false, "msg": "HTTP Error 404: Not Found"}
来重现您的错误pritunl_url
。只有当 pritunl_url
值不同时,问题才会发生。请注意,即使您在 /
末尾有一个 pritunl_url
,脚本也无法正常工作。
我尝试过其他组合,例如,如果 API_TOKEN 错误,我们将得到一个
401
,如果组织名称有错字,它会显示正确的错误等。所以很可能您的问题出在 pritunl_url
。谢谢。