Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After executing 'salt * inventory.audit' ,No data is written to the database #29

Closed
hanzechu01 opened this issue Jun 19, 2019 · 16 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@hanzechu01
Copy link

[WARNING ] /usr/lib/python2.7/site-packages/salt/payload.py:149: DeprecationWarning: encoding is deprecated, Use raw=False instead.
ret = msgpack.loads(msg, use_list=True, ext_hook=ext_type_decoder, encoding=encoding)

salt-syndic-node1:
salt-syndic-node1 properties have not changed

@neilmunday
Copy link
Owner

Hi,

Which operating system(s) are you using on your Salt master and minions?

Which version(s) of SaltStack are you using on your Salt master and minions?

If no records are being written to the database then then it sounds like the issue is on the server side where the inventory.py runner is executed - this script is invoked when presence and audit events are triggered by minions and writes records to the database.

  1. Can you confirm that the server that is your Salt master can access your MySQL server?

  2. Can you confirm that required Python modules are installed on your Salt master? You can check by loading the python interpreter at the command line and then by entering the following commands:

import MySQLdb
import pytz

If either of these import commands fail, then please install the appropriate Python packages for your operating system and try again.

  1. Load two shells on your Salt master and run the following command in the first shell:

tail -f /var/log/salt/master

In the second shell run:

salt '*' inventory.audit force=True

Take a note of any errors that are reported in the first shell in the Salt master log. You can then exit the tail command using Ctrl + C.

  1. If there were no useful errors from the previous step, in the first shell run the following command to view Salt's event queue:

salt-run state.event pretty=True

Now in the second shell run:

salt '*' inventory.audit force=True

There should be a few events appearing in the first shell. Look for any errors in the output.

@neilmunday neilmunday self-assigned this Jun 19, 2019
@neilmunday neilmunday added the help wanted Extra attention is needed label Jun 19, 2019
@hanzechu01
Copy link
Author

Hello
1.My Salt master:
Salt Version:
Salt: 2019.2.0
2.Currently only Centos ,Can you ask if this supports Windows 10?
3.My Salt MAster can connect to the database
4.When I run tail -f
/var/log/salt/master and salt '*' inventory.audit force=True

I found it:
2019-06-20 08:07:29,267 [py.warnings :149 ][WARNING ][102773] /usr/lib/python2.7/site-packages/salt/payload.py:149: DeprecationWarning: encoding is deprecated, Use raw=False instead.
ret = msgpack.loads(msg, use_list=True, ext_hook=ext_type_decoder, encoding=encoding)
2019-06-20 08:07:30,591 [salt.utils.reactor:401 ][ERROR ][5000] Reactor 'inventory_audit' failed to execute runner 'inventory.audit': function not available
2019-06-20 08:07:36,160 [salt.utils.reactor:401 ][ERROR ][5000] Reactor 'inventory_present' failed to execute runner 'inventory.present': function not available

Please help solve this problem

Thank you

@neilmunday
Copy link
Owner

neilmunday commented Jun 20, 2019

The inventory module will not work on Windows 10 Salt Minions as there is Linux specific code in the module. I believe that the runner would work on a Windows 10 Salt Master but this has not been tested.

It looks like your Salt Master cannot find the inventory.py runner.

Can you confirm that you have the following in your /etc/salt/master config file:

extension_modules: /var/lib/salt

If not, please add the above and restart your Salt master.

Also please confirm that /var/lib/salt/runners exists and contains the following files:

  • inventory.ini
  • inventory.py

If not, please copy these files from the runners directory from Salt Minion Inventory download.

Then restart your Salt Master.

Also, do you have selinux enabled?

@hanzechu01
Copy link
Author

hanzechu01 commented Jun 20, 2019

Hello
Now I can confirm extension_modules in /etc/salt/master: /var/lib/salt will already exist
and
/var/lib/salt/runners It exists
Can be seen from the picture
selinunx is shut down
image
image
image
this run tail -f /var/log/salt/master and salt salt-syndic-node1 inventory.audit force=True
after that
I found this
2019-06-20 15:43:10,324 [py.warnings :149 ][WARNING ][7569] /usr/lib/python2.7/site-packages/salt/payload.py:149: DeprecationWarning: encoding is deprecated, Use raw=False instead.
ret = msgpack.loads(msg, use_list=True, ext_hook=ext_type_decoder, encoding=encoding)

@neilmunday
Copy link
Owner

Can you confirm if you are using the SaltStack python 2 or 3 version? From the warning message you have shared I am assuming version 2. I don't see this error on my server which is running the python 2 version of Salt Stack 2019. This could be coming from something else in your SaltStack set-up.

In one of my previous replies I asked if you could run:

salt-run state.event pretty=True

in one shell and then in a second shell run:

salt '*' inventory.audit force=True

Can you share the output from the SaltStack event queue? It should show the inventory.audit function being executed on the minion(s), the result returned to the queue and then the result of the reactor running. Hopefully there will be some useful info here.

@neilmunday
Copy link
Owner

Looks like the warning message you are seeing is due to a known issue: saltstack/salt#52487

It would appear that this fix has been included in Salt Stack 2019.2.1 - there are no RPMs for this version at this time. I don't think that this warning explains why the Salt Minion Inventory isn't working though.

@hanzechu01
Copy link
Author

hanzechu01 commented Jun 21, 2019

hello

Please check the version

image

image

On the picture is my execution
Salt-run state.event pretty=True and salt '*' results of inventory.audit force=True
Sorry, because the queue is too long, there is no way to show you all
image
I saw a lot of data that needs to be written to the database from the queue, but still did not write to the database.

Do you need to set anything else in the salt master?

@neilmunday neilmunday added the bug Something isn't working label Jun 21, 2019
@neilmunday
Copy link
Owner

Thanks for the screen shots.

It looks like the Python interpreter cannot find the ConfigParser module which is normally installed as part of the python-libs RPM under CentOS.

Does /usr/lib64/python2.7/ConfigParser.py exist on your Salt Master? Is the python-libs RPM installed?

@hanzechu01
Copy link
Author

Hello friend !
image
I have this ConfigParser.py exist

@neilmunday
Copy link
Owner

What happens if you try importing the ConfigParser in the Python 2?

E.g. load the python interpreter:

python

Then type:

import ConfigParser

You should see this:

$ python
Python 2.7.5 (default, Apr  9 2019, 14:30:50)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ConfigParser
>>>

@hanzechu01
Copy link
Author

Yes, my results are the same as yours.
image
Is this okay?

@neilmunday
Copy link
Owner

Thanks for the info. Yes, that is the correct output, however I wasn't expecting it to work under your set-up as for some reason the module is not found when running under SaltStack.

I've just made some minor modifications to the runner to make it work with the Python 3 version of SaltStack also. Have you tried this version at some point? I only ask as one of your earlier screen shots shows in /var/lib/salt/runners a sub directory called pycache which is only created when using Python 3.

Please can you try downloading https://raw.githubusercontent.com/neilmunday/Salt-Minion-Inventory/master/runners/inventory.py and saving it to /var/lib/salt/runners/inventory.py. Then restart your Salt Master: systemctl restart salt-master.

Now try the tests above again please.

@hanzechu01
Copy link
Author

image

I downloaded the new Inventory.py and restarted the master's service. After executing salt -l debug 'node1' inventory.audit force = True, it looks like this.

@neilmunday
Copy link
Owner

Looks like you have put a space either side of the equals sign. Please run like so:

salt 'node1' inventory.audit force=True

@hanzechu01
Copy link
Author

Hello friend!
Thank you very much for your support and help. The function has been implemented.

@neilmunday
Copy link
Owner

Excellent - are you happy for this issue to be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants