amendlik / salt-gen-resource

Generate Rundeck node resources from the Salt Mine
Other
8 stars 7 forks source link

Unexpected output #2

Closed Mapel88 closed 5 years ago

Mapel88 commented 5 years ago

Hi,

First - thank you for this script, really great work and very good instructions!

Second, I'm having some issues with '-s' flag and with static attributes option. I'm using Python version 2.7.5 on centos 7

When running the script with -s and/or username=XXX I'm getting the following out put from the script

This is my command: sudo /rundeck/scripts/SaltGenResource.py -s -G 'kernel:windows' username=XXX

this is the result for the rundeck server (-s)

localhost:
  description: Rundeck server node
  hostname: localhost
  osArch: amd64
  osFamily: unix
  osName: !!python/unicode 'Linux'
  osVersion: !!python/unicode '3.10.0-862.14.4.el7.x86_64'
  username: rundeck

This is from some minion:

minion1:
  hostname: minion1
  osName: Windows
  !!python/unicode 'username': !!python/unicode 'pluto'

This is the corresponding errors from rundeck logs:

Caused by: com.dtolabs.rundeck.core.resources.ResourceModelSourceException: com.dtolabs.rundeck.core.resources.format.ResourceFormatParserException: com.dtolabs.rundeck.core.common.NodeFileParserException: could not determine a constructor for the tag tag:yaml.org,2002:python/unicode
 in 'reader', line 12, column 3:
      !!python/unicode 'username': !!p ...
      ^

        at com.dtolabs.rundeck.core.resources.BaseFileResourceModelSource.loadNodes(BaseFileResourceModelSource.java:277)
        at com.dtolabs.rundeck.core.resources.BaseFileResourceModelSource.getNodes(BaseFileResourceModelSource.java:253)
        at com.dtolabs.rundeck.core.resources.BaseFileResourceModelSource.getNodes(BaseFileResourceModelSource.java:236)
        at com.dtolabs.rundeck.core.resources.FileResourceModelSource.parseFile(FileResourceModelSource.java:249)
        at com.dtolabs.rundeck.core.resources.ScriptResourceUtil.executeScript(ScriptResourceUtil.java:152)
        at com.dtolabs.rundeck.core.resources.ScriptResourceModelSource.getNodes(ScriptResourceModelSource.java:156)
        ... 47 more
Caused by: com.dtolabs.rundeck.core.resources.format.ResourceFormatParserException: com.dtolabs.rundeck.core.common.NodeFileParserException: could not determine a constructor for the tag tag:yaml.org,2002:python/unicode
 in 'reader', line 12, column 3:
      !!python/unicode 'username': !!p ...
      ^

        at com.dtolabs.rundeck.core.resources.format.ResourceYamlFormatParser.parseDocument(ResourceYamlFormatParser.java:90)
        at com.dtolabs.rundeck.core.resources.BaseFileResourceModelSource.loadNodes(BaseFileResourceModelSource.java:271)
        ... 52 more
Caused by: com.dtolabs.rundeck.core.common.NodeFileParserException: could not determine a constructor for the tag tag:yaml.org,2002:python/unicode
 in 'reader', line 12, column 3:
      !!python/unicode 'username': !!p ...
      ^

Obviously I shouldn't get this '!!python/unicode' prefix... I can work around it by remarking the following lines:

resources[self._server_node_name] = {
                'hostname':    self._server_node_name,
                'description': 'Rundeck server node',
                'username':    self.options.server_node_user,
                #'osName':      local_grains['kernel'],
                #'osVersion':   local_grains['kernelrelease'],
                'osFamily':    self._os_family(local_grains['kernel']),
               'osArch':      self._os_arch(local_grains['cpuarch'])
            }

and by adding the username hard coded in the script, but thought maybe you have an easy fix for this.

amendlik commented 5 years ago

That issue should be fixed on the develop branch. Would you be able to test that and let me know your results?

Mapel88 commented 5 years ago

Yep It's working! Thank you!

amendlik commented 5 years ago

Fixed under v1.4