How to display salt outputs using table_out.tabledisplay

494 views
Skip to first unread message

Dhanasekaran Nagappan

unread,
Nov 29, 2019, 5:01:44 AM11/29/19
to Salt-users
Team,

We are running 2019.2.2 (latest) saltmaster and salt-minions. 

We would like to write OS validations using salt states. Example: getting hostname, IP, DNS, NTP, Users, firewalld status, selinux status, app status etc.  
We would like to display these outputs with table_out, but don't know how to use output module to display the outputs in table. 
We would like to display exactly same as in https://docs.saltstack.com/en/latest/ref/output/all/salt.output.table_out.html using table_out.tabledisplay.

Please can someone guide?

Thanks,
Sekar.

Clint Allen

unread,
Nov 30, 2019, 2:38:51 PM11/30/19
to Salt-users
You should be able to use the --out arg, for example:

salt --out=table_out minion1 grains.get os

Christian McHugh

unread,
Dec 8, 2019, 2:29:39 PM12/8/19
to Salt-users
I'm not in front of a computer to be able to give an example, but for your need to "write OS validations using salt states. Example: getting hostname, IP, DNS, NTP, Users, firewalld status, selinux status, app status etc and display outputs with table_out" you should look up the saltcheck module. It can perform those validations and like any other salt module, use outputters like table_out.

Anita Krueger

unread,
Dec 9, 2019, 4:48:30 AM12/9/19
to Salt-users
Actually the virtual name of the output module is "table". So to get this running (I never really saw table output though), you would need to do this:

salt 'minion1'grains.get os --out=table



There was an issue to fix the docs and I'm trying to get it re-opened, but no luck so far: https://github.com/saltstack/salt/issues/42960

Dhanasekaran Nagappan

unread,
Dec 16, 2019, 1:43:50 AM12/16/19
to Salt-users
saltcheck looks suitable for me. Let me try and expose. Thank you.

Dhanasekaran Nagappan

unread,
Dec 16, 2019, 1:46:20 AM12/16/19
to Salt-users
I am not able to see any table when i use --out=table or --out=table_out. Is there any exaples which shows the output in table format.

The example shown in saltstack don't have the clear examples. 

Thanks,
Sekar.

Dhanasekar

unread,
Dec 17, 2019, 6:12:20 AM12/17/19
to salt-...@googlegroups.com
Hi McHugh,
The saltcheck would be suitable for my requirement. 
But when i try to run saltcheck.run_state_tests, it takes all states in to cache, which is not suitable for me. Because we have 9 GB of salt states and its related rpms/exe. Not sure how to avoid cache and run only required state cache.

Is it possible to avoid cache and run saltcheck?

On Mon, Dec 9, 2019 at 12:59 AM Christian McHugh <christia...@gmail.com> wrote:
I'm not in front of a computer to be able to give an example, but for your need to "write OS validations using salt states. Example: getting hostname, IP, DNS, NTP, Users, firewalld status, selinux status, app status etc and display outputs with table_out" you should look up the saltcheck module. It can perform those validations and like any other salt module, use outputters like table_out.

--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/ZNbuaoAR51g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/5dd7e01d-6b7d-45de-bdf0-d511a48e2e95%40googlegroups.com.


--
Thanks and Regards,
Dhanasekaran,
9739002795.

Christian McHugh

unread,
Dec 17, 2019, 1:56:30 PM12/17/19
to Salt-users
Hi Dhanasekaran,

I think you got this on linkedin, but for the group record: The way saltcheck locates and caches state files for testing has been reworked for Neon. For now you can try the code from http://github.com/saltstack/salt/pull/55613 and post any comments you might have there. This new version should only cache the actual test and included map files rather than whole state directories. 

As for your table output, you might need to just use json and parse it yourself. In playing around a little, the table and survey runner aren't the most useful with saltcheck output. 
salt '*' saltcheck.run_state_tests common --out=table
master:
----------
    ------------------------------------------------------
    |                       Common                       |
    ------------------------------------------------------
    | {'validate_shell': {'status': 'Pass', 'duration':  |
    |    16.1317}, 'verfity_vim': {'status': 'Pass',     |
    |                'duration': 1.9855}}                |
    ------------------------------------------------------
    | {'Execution Time': 18.1172, 'Passed': 2, 'Failed': |
    |        0, 'Skipped': 0, 'Missing Tests': 0}        |
    ------------------------------------------------------

Or 
salt-run survey.hash '*' saltcheck.run_state_tests common
|_
  ----------
  pool:
      - master
  result:
      [{'common': {'validate_shell': {'status': 'Pass', 'duration': 14.7346}, 'verfity_vim': {'status': 'Pass', 'duration': 2.0605}}}, {'TEST RESULTS': {'Execution Time': 16.7951, 'Passed': 2, 'Failed': 0, 'Skipped': 0, 'Missing Tests': 0}}]

What might work best is saving the json and walking the results for each host and gathering any failures:
salt '*' saltcheck.run_state_tests common --out=json{
    "master": [
        {
            "common": {
                "validate_shell": {
                    "status": "Pass",
                    "duration": 14.7751
                },
                "verfity_vim": {
                    "status": "Pass",
                    "duration": 1.3808
                }
            }
        },
        {
            "TEST RESULTS": {
                "Execution Time": 16.1559,
                "Passed": 2,
                "Failed": 0,
                "Skipped": 0,
                "Missing Tests": 0
            }
        }
    ]
}


Dhanasekar

unread,
Dec 17, 2019, 2:11:02 PM12/17/19
to salt-...@googlegroups.com
Thanks McHugh. Yes, we interacted in Linkedin. 

My intention is not use table format for saltcheck. My aim was to do OS QC using some output formats. Later i came to know about saltcheck and exploring now. But initially i am not aware of saltcheck and checking for table format output. 

--
You received this message because you are subscribed to a topic in the Google Groups "Salt-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/salt-users/ZNbuaoAR51g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to salt-users+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages