saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.17k stars 5.48k forks source link

GCE Salt-Cloud Driver:creating node with custom subnetwork not possible? #31071

Closed shpsec-dennis closed 6 years ago

shpsec-dennis commented 8 years ago

Hi,

Combing the libcloud (1) and gce provider source code in saltstack(2) and docs I cannot seem to figure out how to create a GCE instance into a custom sub-network either using a profile or salt-module.

Is this support just not existing or can I not figure out how to do it? (similar to EC2: [https://issues.apache.org/jira/browse/LIBCLOUD-579])

If I specify a subnetwork for the network attribute in a cloud-profile it says the network does not exist. If I specify the main network this happens:

$ sudo -H salt-cloud -p prom-gce prom1
(reverse-i-search)`vi ': sudo vi /etc/salt/minion
$ sudo vim /etc/salt/cloud.profiles.d/prometheus.conf
Password:
$ sudo -H salt-cloud -p prom-gce prom1
[INFO    ] salt-cloud starting
[INFO    ] Creating GCE instance prom1 in us-central1-b
[ERROR   ] Error creating prom1 on GCE

The following exception was thrown by libcloud when trying to run the initial deployment:
{u'domain': u'global', u'message': u"Invalid value for field 'resource.networkInterfaces[0].subnetwork': ''.  Subnetwork was not specified for a custom network.", u'reason': u'invalid'}
Error: There was a profile error: Failed to deploy VM

So how do I win? Can I not use subnetworks in my project?

(1) [https://github.com/apache/libcloud/blob/trunk/libcloud/compute/drivers/gce.py#L2255] nothing about subnetwork in create_node() unless something else happens.

(2) https://docs.saltstack.com/en/latest/ref/clouds/all/salt.cloud.clouds.gce.html

The google cloud APIs support this: https://cloud.google.com/compute/docs/reference/latest/instances


$ salt --versions-report
Salt Version:
           Salt: 2015.8.5

Dependency Versions:
         Jinja2: 2.8
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.2.0
         Python: 2.7.10 (default, Aug 22 2015, 20:33:39)
           RAET: Not Installed
        Tornado: 4.3
            ZMQ: 4.1.2
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.4.2
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libgit2: Not Installed
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist:
        machine: x86_64
        release: 15.0.0
         system: 10.11.1 -- x86_64
erjohnso commented 8 years ago

Hi @shpsec-dennis - you're research is correct. Subnetworks do not yet exist in libcloud and that has to happen before they can get exposed to the salt-cloud GCE driver.

Could you create a libcloud issue for the feature request and point back to this issue? Also, if you're inclined to do the work, I'd be happy to help review / test.

emcgough commented 8 years ago

What is the https://issues.apache.org/jira/browse/LIBCLOUD/ ticket number? Would like to help get this fixed.

daodennis-zz commented 8 years ago

I did not create one, sorry about dropping the ball there.

replicant0wnz commented 7 years ago

Looks like it's been added:

https://libcloud.readthedocs.io/en/latest/compute/drivers/gce.html

ex_subnetwork (str or GCESubnetwork) – The subnetwork to associate with the node.

Inveracity commented 7 years ago

I just got this working in salt-cloud, pull request inbound

Inveracity commented 7 years ago

With this pull request your profile should look like this:

  network: mycustomnetwork
  subnetwork: mycustomsubnet01
  external_ip: mystaticip
stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.