Giter VIP home page Giter VIP logo

salt-gen-resource's People

Contributors

amendlik avatar compunautics avatar dependabot[bot] avatar fdevans avatar mapel88 avatar some-natalie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

salt-gen-resource's Issues

Use compound flag in rundeck doesn't work

Hi,

This is not really an issue with the script itself because it's working just fine, more of a consult if you don't mind...
I'm trying to use the compound feature in rundeck, but it doesn't seem to work...

When running the script as follows I'm getting the desired output:
SaltGenResource.py -t roles -C 'G@region:region and G@roles:role1 or G@roles:role2 or G@roles:role3'
When I put the same arguments in rundeck I don't get any nodes...

Do you, perhaps, have an example on how to use the compound flag in rundeck?
I think it can't handle the ''.

Would be very much appreciated...

Thanks in advance.

Unexpected output

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.

Python3 update?

Hey,

I was cloning this repo to my Rundeck server as per readme and then i tried to run the script.
it was not happy about #!/usr/bin/env python
i am on a brand new ubuntu 22.04 server, changing python to python3 fixed the executable :)

[Breakage] 2 bugs with recent version of Saltstack

Hi @amendlik, I am using SaltGenResource.py for years now. Everything was working fine but..
I just figured out that rundeck was not refreshing anymore with my minion list.
I isolated 2 bugs that seems to be likely related with v3005 release but not 100% sure (maybe bugs arrived with v3004.x).

Bug 1:

root@rundeck_machine:~# sudo python3 /var/lib/rundeck/libext/SaltGenResource.py -s "*" -a manufacturer,os_family,os,osmajorrelease,osrelease,virtual,saltversion,saltenv username="rundeck"
Usage: SaltGenResource.py [options] <target> [<attr>=<value> ...]

SaltGenResource.py: error: Error while processing <function LogLevelMixIn.__setup_logfile_logger_config at 0x7f43f7cac268>: Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/salt/utils/parsers.py", line 212, in parse_args
    mixin_after_parsed_func(self)
  File "/usr/lib/python3/dist-packages/salt/utils/parsers.py", line 783, in __setup_logfile_logger_config
    if self.config[self._logfile_loglevel_config_setting_name_] != "quiet":
KeyError: 'resource_generator_log_level_logfile'

Some potential modification in saltstack/salt gives rise to ignore resource_generator_log_level_logfile default value specified in Readme.md of this plugin.
I found a workaround by hardcoding resource_generator_log_level_logfile: "warning" in my minion config

Bug 2:

root@rundeck_machine:~# sudo python3 /var/lib/rundeck/libext/SaltGenResource.py -s "*" -a manufacturer,os_family,os,osmajorrelease,osrelease,virtual,saltversion,saltenv username="rundeck"
[ERROR   ] An un-handled exception was caught by Salt's global exception handler:
AttributeError: 'SaltNodesCommandParser' object has no attribute 'setup_logfile_logger_config'
Traceback (most recent call last):
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 431, in <module>
    print(ResourceGenerator().as_yaml())
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 213, in __init__
    parser.setup_logfile_logger_config()
AttributeError: 'SaltNodesCommandParser' object has no attribute 'setup_logfile_logger_config'
Traceback (most recent call last):
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 431, in <module>
    print(ResourceGenerator().as_yaml())
  File "/var/lib/rundeck/libext/SaltGenResource.py", line 213, in __init__
    parser.setup_logfile_logger_config()
AttributeError: 'SaltNodesCommandParser' object has no attribute 'setup_logfile_logger_config'

I found a workaround by commenting problematic line https://github.com/amendlik/salt-gen-resource/blob/master/SaltGenResource.py#L265 and everything seems to work fine again.

Since I do not master developing with Salt Python API and I don't know how you want address this issues (keeping backward compatibility if something break with previous versions of Salt or making a deeper refactor for example), I prefer to open this issue to track these bugs rather than to open an incomplete Pull Request.

pip3 + salt package

Hey,

On this new install i have, i had to install pip3 & then pip3 install salt to make the script run.
the docs didn't say anything about it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.