Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.

Add the ability to manage remote systems via ssh#67

Merged
lutter merged 32 commits intopuppetlabs-toy-chest:masterfrom
lutter:ssh
Nov 8, 2017
Merged

Add the ability to manage remote systems via ssh#67
lutter merged 32 commits intopuppetlabs-toy-chest:masterfrom
lutter:ssh

Conversation

@lutter
Copy link
Contributor

@lutter lutter commented Oct 21, 2017

This makes it possible to access a remote system that has nothing (or not very much) in terms of prerequisites on it. A prebuilt tarball is available that makes it possible to use these changes on a system. After downloading, unpack it somewhere and run ./ral/bin/ralsh; it will work on any glibc based Linux machine (e.g., CentOS 6 and 7). See ralsh --help for usage information, especially the new --target and --sudo options.

Remote access is purely through the ssh and scp command line tools, and makes heavy use of control sockets to reuse an existing session.

Requirements to use this:

  • the controller must have ssh and scp installed
  • passwordless access to the remote node must be possible
  • the remote node must have which, rm, mv, chown, chmod, mktemp, and dd on it (these could mostly be removed by using sftp instead of scp)

Providers are properly checked for suitability; notice how running ralsh and ralsh -t somehost will list different providers; several providers (file::posix, user::useradd, and group::groupadd) have not been adapted to remote use.

External providers (scripts like systemd.prov) are uploaded to the target system and run there, internal providers like host and mount simply retrieve files from the target and process them on the controller (and write them back to the remote) Such providers also run commands 'over the wire'; e.g., the mount provider will run mount/umount via ssh. Also, the package::dnf provider is broken right now and fails.

The interface for dealing with a remote system is defined in target/base.hpp and the implementation of ssh access is in target/ssh.cc

One thing that makes this slow is that currently the provider lifecycle forces providers to eagerly load files they need to process. That part of the API needs to be improved to separate listing and interrogating provider metadata from full provider initialization. Even with that, ralsh is quite usable even with a system 40ms away.

Making the remaining providers work:

  • user and group need to stop using POSIX API's to access /etc/passwd and /etc/group and instead use Augeas for that; other than that, they follow the same pattens as host and mount
  • file requires that the target API be expanded. Some aspects of file management (e.g., reading permissions) will require additional capabilities in that interface, some operations, like managing SELinux context, will always be hard.
  • the dnf provider requires that we upload more than one file per provider as it is split across two files
  • the ssh_authorized_key provider is written in mruby; we can instrument mruby similar to what the target classes do to make that work (or, of course, upload an mruby interpreter to the target)

lutter added 28 commits November 7, 2017 17:40
The target classes abstract how we interact with the system we are managing
It's now possible to just list what commands a provider requires to
indicate its suitability, something like

  suitable:
    commands:
      - ls
      - df
Since running a provider with ral_action=describe is slow, it's now
possible to store its metadata in a separate YAML file. For a provider
mine.prov, if mine.yaml exists, we just read that; if it's not there, we'll
still run the describe action of the provider.
The addition of a reader and writer makes it possible to load and save the
tree manually so that users of the tree can be unaware of where files come
from (e.g., not the local system)
When creating an augeas handle for an ssh target, we manually read and
write files through our ssh connection rather than trying to load htem from
the local system.
When using search expressions like /files/etc/hosts/*[ipaddr= '127.0.0.1']
to specify a node, we can 'lose' the node if its ipaddr field
changes. resolve() makes it possible to turn the path into something that
does not involve any searches, e.g. /files/etc/hosts/1, addressing this
problem
Otherwise, we fail to set properties on an existing mount because the base
path contains a search that will not work after erasing its contents
We didn't check for missing mandatory entries before, and didn't pass all
errors back up properly
We were uploading external commands every time we tried to determine if
they are suitable - that defeats the purpose of external metadata.
@lutter lutter merged commit b531ab8 into puppetlabs-toy-chest:master Nov 8, 2017
@lutter lutter deleted the ssh branch November 8, 2017 19:05
@lutter lutter changed the title WIP: add the ability to manage remote systems via ssh Add the ability to manage remote systems via ssh Nov 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant