小编StF*_*tFS的帖子

依赖 Ansible 角色中“组合”默认变量的延迟评估

我有两个 Ansible 角色,我们称它们为postgresmyservice

在我的postgres角色中,我定义了一些默认变量(在 中postgres/defaults/main.yml):

postgres_db: pgdb
postgres_user: postgres
postgres_systemd_docker_service_name: postgres_{{postgres_db}}
Run Code Online (Sandbox Code Playgroud)

在我的postgres角色中,我从postgres_systemd_docker_service_name变量创建了一个 systemd 服务单元文件。这里的想法是,如果我想为多个服务运行多个 postgres docker 容器,我可以使用postgres_db变量区分它们。

然后我有了myservice角色,在其中我依赖于postgres角色并覆盖一些默认变量。

在我的myservice/meta/main.yml

dependencies:
  - {role: docker}
  - role: postgres
    postgres_user: "myservice_user"
    postgres_password: "myservice_password"
    postgres_db: "myservice"
Run Code Online (Sandbox Code Playgroud)

但是,当我运行使用该myservice角色的剧本时,它会将我的 systemd 单元文件创建为postgres_pgdb(这是默认值)而不是postgres_myservice.

如果我postgres_systemd_docker_service_name在我的myservice角色中使用该变量,它会被评估为postgres_myservice.

有什么方法可以确保我的postgres角色中的复合变量以我的myservice角色可以覆盖默认值的方式进行评估?

ansible

5
推荐指数
1
解决办法
1520
查看次数

openconnect VPN 可在 KDE NetworkManager 小部件中使用,但不能在命令行上使用

我需要连接到 Linux 上的 Cisco VPN,首先我使用 KDE NetworkManager Plasma 小部件来完成此操作。效果很好,如果我从网络管理器小部件中选择 VPN,我就可以连接到 VPN。

\n\n

但是,如果我尝试使用命令行,则无法正常工作(IP 和 URL 已更改以保护无辜者):

\n\n
\xe2\x9e\x9c  ~  sudo openconnect --proxy http://proxy.mycompany.com:8080 vpn.mycompany.com:443 \nPOST https://vpn.mycompany.com/\nAttempting to connect to proxy 172.17.122.135:8080\nRequesting HTTP proxy connection to vpn.mycompany.com:443\nUnexpected continuation line after CONNECT response: \'Via: 1.1 SPROXY2\'\nUnexpected continuation line after CONNECT response: \'X-WebMarshal-RequestID: 445D5E14-309A-4AA2-B7AF-07CAAD5BB21D\'\nSSL negotiation with vpn.mycompany.com\nServer certificate verify failed: signer not found\n\nCertificate from VPN server "vpn.mycompany.com" failed verification.\nReason: signer not found\nEnter \'yes\' to accept, \'no\' to abort; anything else to view: yes\nConnected …
Run Code Online (Sandbox Code Playgroud)

vpn proxy networkmanager openconnect ubuntu-14.04

2
推荐指数
1
解决办法
4894
查看次数

标签 统计

ansible ×1

networkmanager ×1

openconnect ×1

proxy ×1

ubuntu-14.04 ×1

vpn ×1