0

I am curious if Linux have anything close to what PowerShell can do when come to managing servers in Enterprise? For example, retrieving server's information on a big scale and also making changes.I knew that Posh is getting in into Linux territory but I am not sure how much can it do to Linux Also,can Linux return it data in a more structural way in the form of objects and etc?

1
  • Hi, I think it will be hard for other users to give you a good answer to this question. Would you mind outlining a little what you are trying to achieve? What I mean is: Is the question related to infrastructure automation or compliance or is there an entirely different background. Always remember: People will be more likely to give you a precise and helpful answer the more precisde your question!
    – juwi
    Mar 23, 2022 at 15:03

3 Answers 3

1

PowerShell is just a scripting language. By itself it is no more powerful or useful than any other scripting language or tool.

IMHO You're mistaking the (power of that) tool with the convenience and power that a single management domain such as Active Directory provides.

But yes, Linux systems can also be integrated in a single management domain, in AD even but there are also (Open Source) alternatives. And yes Linux provides tooling to use such management domains effectively for the large scale management of systems.

https://en.wikipedia.org/wiki/List_of_systems_management_systems

https://en.wikipedia.org/wiki/Comparison_of_open-source_configuration_management_software

https://en.wikipedia.org/wiki/System_Security_Services_Daemon

https://github.com/puppetlabs/facter

1
  • You maybe right on that POSH is only as good as the existence of AD. But POSH do offered extensive accesibility to each classes like GWMI (yeah kerberos authentication or similar is needed). I am sure one of the links you given might have what I need. Thanks Mar 24, 2022 at 5:15
0

To manage linux servers in bulk I personally use pssh (parallel ssh), as well as configuration management (CM) tools like puppet/ansible/chef to administrate machines in bulk. CM tools are kind of like manifests (this file should be here, that program should always be running, etc), and parallel ssh is just like running single bash commands, except on a large number of machines at once. There's probably a lot of other tools for doing the same thing, with linux there's usually many good ways of doing anything (except reading html email from the command line).

While bash and the linux userspace tools do not have a concept of objects, their text and data processing capabilities are fantastic and it has close to no size limitations. Additionally quite literally everything usable from the command line is designed to be used in bash scripts as well. The end result is extremely powerful.

3
  • That maybe the closest of what I am looking for. But like you said, you probably get a bunch of strings. Can you elaborate more about the text and data processing capabilities? I appreciate your feedback Mar 24, 2022 at 5:10
  • You can sort an unlimited amount of data (as far as i can tell), deduplicate, tokenize - split it up based on characters or columns both smart and dumb, substitute words, search or substitute based on regex (a sort of search/replace/etc language), feed it to any command line tool as input or parameters, compress repeating characters, and more - pretty much any other sort of data manipulation you can think of. There's even this tool called diff that given quite literally any two files will tell you the minimum number of changes to turn file1 into file2. Mar 24, 2022 at 22:01
  • Like the ability to feed data to other tools in millions of ways is really useful too. You can pipe the output of a cli command to a tool that stores everything in the clipboard. You can make the command line treat the output of a command like a file... i mean the possibilities seem pretty much unlimited. Mar 24, 2022 at 22:02
0

I use Ansible and love it. What really hooked me at first was the ansible_facts. One simple playbook would return a scathing amount of information about a given system. Early on I just saved the output and grep'd it for the key:value pair I wanted. There's probably a better way to do that.

In the simplest configuration example, you keep an "inventory" of hosts you want to run Ansible on. It's something like:

[my_hosts]
host1.mydomain.com
host2.mydomain.com
...

Then you can run an Ansible "playbook" on my_hosts and it will hit every host you have configured in that block. A playbook is just a YAML configuration containing commands, variables and formatting which Ansible understands. It's not a shell script. It's a "way" to tell Ansible what to do on a host. It took me a while to wrap my head around it.

Again, for simplicity sake, you can make a playbook that runs a shell command and run that playbook on every host. Here's an "uptime" playbook I used often.

---
- hosts: all
  gather_facts: false

  tasks:
    - name: uptime for host
      shell: uptime
      register: output

    - debug: var=output.stdout_lines

    # print a formatted line for grep/sed mining
    - debug: msg="grepme {{ inventory_hostname }}:{{ output.stdout_lines}}"

Things get way more involved that this but it's daunting to first get started. Keeping things simple with just shell commands can get your feet wet but once you get beyond simple things, you should look into more "Ansibly" ways of doing things which are more complex and harder to work with, but they do pay off.

2
  • Hows the output like ?I heard Ansible is pretty useful in linux Mar 24, 2022 at 5:16
  • The output isn't one-line-per-host type of thing you easily grep or sed but when you have a need for that, you just print out the formatting in a debug task. I'll update my answer with and example.
    – Nstevens
    Mar 31, 2022 at 9:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.