pythongoogle-compute-engineansiblelibcloud

Ansible - Create GCE node with fixed IP


I want to create a GCE node with ansible and attach it a fixed IP. My problem is ansible doesn't seem to purpose this option.

After googling and searching in source code, I can't find where is the code which deploy instances.

If anyone has an idea ?


Solution

  • I didn't find it in ansible's source because it is in ansible-modules-core.

    After make a voluntary error with a bad zone, I had this traceback:

    $ ansible-playbook create_vm.yml  -i inventory/
    PLAY [Create instance(s)] *****************************************************
    
    TASK: [Launch instances] ******************************************************
    failed: [localhost] => {"failed": true, "parsed": false}
    Traceback (most recent call last):
      File "/home/zulu/.ansible/tmp/ansible-tmp-1418774247.2-93981074391261/gce", line 2131, in <module>
        main()
      File "/home/zulu/.ansible/tmp/ansible-tmp-1418774247.2-93981074391261/gce", line 458, in main
        module, gce, inames)
      File "/home/zulu/.ansible/tmp/ansible-tmp-1418774247.2-93981074391261/gce", line 278, in create_instances
        lc_machine_type = gce.ex_get_size(machine_type)
      File "/usr/local/lib/python2.7/dist-packages/libcloud/compute/drivers/gce.py", line 2240, in ex_get_size
        zone = self.ex_get_zone(zone)
      File "/usr/local/lib/python2.7/dist-packages/libcloud/compute/drivers/gce.py", line 2333, in ex_get_zone
        if name.startswith('https://'):
    AttributeError: 'NoneType' object has no attribute 'startswith'
    

    In fact, tasks were launched by the temporary script /home/zulu/.ansible/tmp/ansible-tmp-1418774247.2-93981074391261/gce and after searched for it in my local source code, I found it !

    The code I searched is originally stored in a the git submodule: https://github.com/ansible/ansible/tree/devel/lib/ansible/modules

    I've made a pull request for add external_ips option: PR #539