salt icon indicating copy to clipboard operation
salt copied to clipboard

runner/state cloud.profile fails, salt-cloud -p works

Open funkknight opened this issue 10 years ago • 12 comments

Description of Issue/Question

Trying to create VMware vms using salt.

Works: salt-cloud -p default-profile salttest.domain.net Fails: salt-run cloud.profile default-profile salttest.domain.net Fails: salt 'saltmaster*' state.apply test_cloud

( all other cloud commands that I have tried so far work, e.g. destroy, list*, etc)

I was able to work around the failing commands by changing line 1399 in salt/cloud/__init__.py from

    vms[node] = mapped_providers[prov][prov_name][node]

to

    vms[node] = {}

Setup

/etc/salt/cloud.profiles.d/vmware.conf

'default-profile':
    provider: 'vcenter'
    clonefrom: 'centos7-template'
    num_cpus: 2
    memory: 2GB
    devices:
        disk:
            Hard disk 1:
                size: 16
        network:
            Network adapter 1:
                name: dv-lab
                switch_type: distributed
    datastore: LAB-DISK
    datacenter: lab-dc
    cluster: lab-cluster
    deploy: True
    template: False
    power_on: True
    ssh_username: root
    password: thisisnotthepasswordyouthinkitis
    minion:
      master: saltmaster-dev01.domain.net

/srv/salt/test_cloud.sls

salttest.domain.net:
  cloud.profile:
    - profile: default-profile

Steps to Reproduce Issue

runner fail

[root@saltmaster-dev01 ~]# salt-run cloud.profile default-profile salttest.domain.net
[WARNING ] /usr/lib/python2.7/site-packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)

Exception occurred in runner cloud.profile: Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 342, in low
    data['return'] = self.functions[fun](*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/runners/cloud.py", line 110, in profile
    info = client.profile(prof, instances, **kwargs)
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 350, in profile
    mapper.run_profile(profile, names, vm_overrides=vm_overrides)
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1406, in run_profile
    vms[node]['provider'] = prov
TypeError: 'bool' object does not support item assignment

state fail

root@saltmaster-dev01 ~]# salt 'saltmaster*' state.apply test_cloud
saltmaster-dev01.domain.net
----------
          ID: salttest.domain.net
    Function: cloud.profile
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/usr/lib/python2.7/site-packages/salt/state.py", line 1626, in call
                  **cdata['kwargs'])
                File "/usr/lib/python2.7/site-packages/salt/loader.py", line 1492, in wrapper
                  return f(*args, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/states/cloud.py", line 272, in profile
                  info = __salt__['cloud.profile'](profile, name, vm_overrides=kwargs)
                File "/usr/lib/python2.7/site-packages/salt/modules/cloud.py", line 196, in profile_
                  info = client.profile(profile, names, vm_overrides=vm_overrides, **kwargs)
                File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 350, in profile
                  mapper.run_profile(profile, names, vm_overrides=vm_overrides)
                File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1400, in run_profile
                  # print( mapped_providers[prov][prov_name][node] )
              TypeError: 'bool' object does not support item assignment
     Started: 15:38:43.408934
    Duration: 1106.654 ms
     Changes:

Versions Report

Salt Version:
           Salt: 2015.8.8.2

Dependency Versions:
         Jinja2: 2.7.2
       M2Crypto: Not Installed
           Mako: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.7.0
         Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
           RAET: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
           cffi: 0.8.6
       cherrypy: 3.2.2
       dateutil: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
        libgit2: 0.21.0
        libnacl: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: 2.14
       pycrypto: 2.6.1
         pygit2: 0.21.4
   python-gnupg: Not Installed
          smmap: Not Installed
        timelib: Not Installed

System Versions:
           dist: centos 7.2.1511 Core
        machine: x86_64
        release: 3.10.0-327.10.1.el7.x86_64
         system: CentOS Linux 7.2.1511 Core

funkknight avatar Mar 31 '16 16:03 funkknight

@funkknight, thanks for reporting. There is another open issue on the cloud state, but I cannot find it.

jfindlay avatar Mar 31 '16 18:03 jfindlay

Hello,

I'm experiencing the same issue with Salt Open 2015.8.8+ds-2 / Debian 8.4 64 Bits.

Do you have news by any chance?

aanriot avatar Apr 13 '16 13:04 aanriot

perhaps not helpfull for this issue directly.. but ensure you run in debug mode ... had same error message but found that the vmware driver just was not installed... that was for provider or driver: vmware

steverweber avatar Aug 12 '16 18:08 steverweber

So I found where this is happening in the code and why but not sure I know how to fix it.

/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py

for prov in mapped_providers:
    prov_name = mapped_providers[prov].keys()[0]
        for node in mapped_providers[prov][prov_name]:
            vms[node] = mapped_providers[prov][prov_name][node]
            vms[node]['provider'] = prov
            vms[node]['driver'] = prov_name

When you run this in AWS vms[node] = .... is provided a dictionary value When you run this in vSphere vms[node] = ... is provided a TRUE value so the remaining dictionary additions fail.

My work around was this

for prov in mapped_providers:
    prov_name = mapped_providers[prov].keys()[0]
    for node in mapped_providers[prov][prov_name]:
        if type(mapped_providers[prov][prov_name][node]) is dict:
            vms[node] = mapped_providers[prov][prov_name][node]
        else:
            vms[node] = {}
        vms[node]['provider'] = prov
        vms[node]['driver'] = prov_name

trebortech avatar Aug 17 '16 04:08 trebortech

I also have this issue... not sure what it is... did a similar workaround.

                if mapped_providers[prov][prov_name][node] == True:
                    vms[node] = {}
                else: 
                    vms[node] = mapped_providers[prov][prov_name][node]

steverweber avatar Aug 18 '16 21:08 steverweber

im using salt-call state.highstate. hava a state that does the deployment. cloud config is stored in pillar

steverweber avatar Aug 18 '16 21:08 steverweber

The suggested fix worked for me.

vms[node] = mapped_providers[prov][prov_name][node] to

vms[node] = {}

grep4linux avatar Sep 07 '16 17:09 grep4linux

ZD-939

rickh563 avatar Sep 08 '16 15:09 rickh563

don't think that hack is a /fix/... anyways @nmadhok something to look at here.

steverweber avatar Sep 09 '16 16:09 steverweber

Working for me.

ikkaro avatar Sep 21 '16 09:09 ikkaro

Here are my current findings:

2016.3.2: Fails with stacktrace listed above 2016.3.3: Also fails Head of 2016.3 branch: works (so should be fixed in upcoming 2016.3.4) Head of Carbon branch: works (so should be fixed in upcoming 2016.11.0)

It looks like this PR fixed this problem: #35815

I'm going to close this ticket for now. I'm the assignee, so if this doesn't prove to be the case for you please comment and we'll get it reopened and have another look at it.

cro avatar Oct 18 '16 22:10 cro

this fix seems to fix this issue.. please ignore my previous deleted messages. I have another issue with the vmware driver.

steverweber avatar Oct 19 '16 14:10 steverweber