Results 1 to 2 of 2

Thread: mirroring systemctl on remote system

  1. #1
    Join Date
    Oct 2017
    Beans
    3

    mirroring systemctl on remote system

    I can run systemctl --host username@192.168.1.42 status servicename then enter the password and I get the status of servicename on a remote host, I can also stop/start/etc....Would it be possible to build a local service that is basically just that "remote" command? In essance creating a local mirror of a service on a remote machine? It would have to include the password too, which this being an internal network isn't an issue for security.

  2. #2
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,907
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: mirroring systemctl on remote system

    Quote Originally Posted by tjcstuart View Post
    I can run systemctl --host username@192.168.1.42 status servicename then enter the password and I get the status of servicename on a remote host, I can also stop/start/etc....Would it be possible to build a local service that is basically just that "remote" command? In essance creating a local mirror of a service on a remote machine? It would have to include the password too, which this being an internal network isn't an issue for security.
    You might want to look into Ansible...
    https://www.ansible.com/community

    With Ansible you can define so called "playbooks" that say e.g. you want a certain service on a certain port running. You also define a hosts inventory file where you can group your servers by function, location, OS, distribution ... or all of those criteria.

    You'd then execute that playbook and apply it on all your servers e.g. in Europe. And Ansible will reply with "OK" messages when it didn't need to do anything (the server was already configured the way you want), "changed" when it actually needed to do something (e.g. activate the service), or "failed" if it wasn't able to connect to the server you wanted (e.g. because it's down for maintenance).

    The point being that you get what you wanted: Multiple servers are then configured exactly the same way and are doing exactly the same thing and are running exactly the same services. Or not running them.... depending on what your Playbook is telling them to do or not.

    So there's no need to "reinvent the wheel". Ansible already offers these possibilities and if you are in charge of multiple servers (e.g. because of your job?) you should definitely investigate further and consider learning it.


    EDIT: Link corrected.
    Last edited by scorp123; October 25th, 2020 at 01:12 PM. Reason: URL corrected

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •