2021年3月13日星期六

Creation GCP ressource and get IP adresse

I must create new nexus server on GCP. I have decided to use nfs point for datastorage. All must be done with ansible ( instance is already created with terraform)

I must get the dynamic IP setted by GCP and create the mount point.

It's working fine with gcloud command, but how to get only IP info ?

Code:

- name: get info    shell: gcloud filestore instances describe nfsnexus --project=xxxxx --zone=xxxxx --format='get(networks.ipAddresses)'    register: ip      - name: Print all available facts    ansible.builtin.debug:      msg: ""  

result:

ok: [nexus-ppd.preprod.d-aim.com] => {      "changed": false,      "msg": {          "ansible_facts": {              "discovered_interpreter_python": "/usr/bin/python3"          },          "changed": true,          "cmd": "gcloud filestore instances describe nfsnexus --project=xxxxx --zone=xxxxx  --format='get(networks.ipAddresses)'",          "delta": "0:00:00.763235",          "end": "2021-03-14 00:33:43.727857",          "failed": false,          "rc": 0,          "start": "2021-03-14 00:33:42.964622",          "stderr": "",          "stderr_lines": [],          "stdout": "['1x.x.x.1xx']",          "stdout_lines": [              "['1x.x.x.1xx']"          ]      }  }  

Thanks

https://stackoverflow.com/questions/66619952/creation-gcp-ressource-and-get-ip-adresse March 14, 2021 at 08:37AM

没有评论:

发表评论