大网数据广告活动
服务器运维问答

Use ansible gcp modules to create Cloud NAT

· 52CE 我爱测

I am currently struggling to configure Cloud NAT in gcp via ansible . I was able to set up the Cloud NAT as described in the documentation: https://cloud.google.com/nat/docs/gke-example with gcloud commands, doing basically the t…

问题原文

原帖链接 · Thomas Böhm · CC BY-SA 4.0

I am currently struggling to configure Cloud NAT in gcp via ansible.

I was able to set up the Cloud NAT as described in the documentation: https://cloud.google.com/nat/docs/gke-example with gcloud commands, doing basically the three steps create bastion, create router, configure NAT of created router, which worked as expected.

Therefore, I executed the following commands manually:

  • gcloud compute instances create bastion-1...
  • gcloud compute routers create nat-router...
  • gcloud compute routers nats create nat-config...

The ... is the rest of the commands with region etc which are probably not needed for the question.

Now I want to create an ansible role to do the same. Currently, I was able to create the bastion host via the modules:

  • gcp_compute_disk
  • gcp_compute_network
  • gcp_compute_instance

and the router itself via

  • gcp_compute_router

so step 1 and 2 are done. However, I cannot figure out, if the NAT for the router can be configured via ansible. I couldn't find a corresponding module in the google cloud module list https://docs.ansible.com/ansible/latest/modules/list_of_cloud_modules.html#google or relevant fields to set in the gcp_compute_router-module https://docs.ansible.com/ansible/latest/modules/gcp_compute_router_module.html#gcp-compute-router-module.

Now my question is: Is it possible to configure gcp Cloud NAT via ansible, and if so, do I have to execute shell commands in my playbook or are there modules I can use? Am I overlooking something?

If any information is missing or irrelevant, or I should extend the example code parts, please let me know, so I can edit my question.

已采纳解答

原帖链接 · DavidC · CC BY-SA 4.0

It's seems Ansible doesn't have implemented that functions in the present modules for GCP. You can work around this by running the explicit gcp commands to complete the missing steps, on the machine running Ansible as a command on your playbook, check these examples

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。