All Projects → austinhyde → ansible-sshjail

austinhyde / ansible-sshjail

Licence: MIT license
An Ansible connection plugin for provisioning FreeBSD jails remotely

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
Jinja
831 projects

Projects that are alternatives of or similar to ansible-sshjail

jail exporter
A Prometheus exporter for FreeBSD jail metrics
Stars: ✭ 21 (-63.16%)
Mutual labels:  freebsd, jail
potluck
This project contains the FreeBSD pot (jail) (pkg install pot) flavours which are regularly built with Jenkins and published on potluck.honeyguide.net.
Stars: ✭ 23 (-59.65%)
Mutual labels:  freebsd, jail
ioc
libioc command line tool for BSD jail management
Stars: ✭ 13 (-77.19%)
Mutual labels:  freebsd, jail
knast
Experimental OCI & CRI-compatible container runtimes for FreeBSD
Stars: ✭ 20 (-64.91%)
Mutual labels:  freebsd, freebsd-jails
libjail-rs
Rust implementation of a FreeBSD jail library
Stars: ✭ 32 (-43.86%)
Mutual labels:  freebsd, freebsd-jails
control-pane
ClonOS WEB control panel (CBSD WEB UI)
Stars: ✭ 112 (+96.49%)
Mutual labels:  freebsd, jail
jailman
Automated iocage Jail manager for FreeNAS
Stars: ✭ 26 (-54.39%)
Mutual labels:  freebsd, freebsd-jails
libioc
A Python library to manage jails with ioc{age,ell}
Stars: ✭ 38 (-33.33%)
Mutual labels:  freebsd, jail
vagrant-templates
Vagrantfiles for self-contained development/test environments.
Stars: ✭ 28 (-50.88%)
Mutual labels:  freebsd
Pokedex
Pokedex is a robust Discord bot that mimics the iconic Pokedex from the Pokemon games and show. It's loaded with features to help players of all skill levels to learn and better enjoy Pokemon! The goal of Pokedex is to provide users with as much data about the Pokemon games as they desire conveniently and with minimal effort.
Stars: ✭ 18 (-68.42%)
Mutual labels:  configuration-management
agollo
🚀Go client for ctrip/apollo (https://github.com/apolloconfig/apollo)
Stars: ✭ 563 (+887.72%)
Mutual labels:  configuration-management
irsync
rsync on interval, via command line binary or docker container. Server and IOT builds for pull or push based device content management.
Stars: ✭ 19 (-66.67%)
Mutual labels:  configuration-management
airyx
A BSD-based OS project that aims to provide an experience like and some compatibility with macOS (formerly known as airyxOS)
Stars: ✭ 2,490 (+4268.42%)
Mutual labels:  freebsd
configi.old
Bloat-free configuration management
Stars: ✭ 35 (-38.6%)
Mutual labels:  configuration-management
i3configger
i3 config manipulation tool
Stars: ✭ 23 (-59.65%)
Mutual labels:  configuration-management
octopkg
A Qt-based pkgng (BSD) front end
Stars: ✭ 33 (-42.11%)
Mutual labels:  freebsd
holo
Minimalistic configuration management
Stars: ✭ 88 (+54.39%)
Mutual labels:  configuration-management
ZRouter
No description or website provided.
Stars: ✭ 16 (-71.93%)
Mutual labels:  freebsd
GoRAT
GoRAT (Go Remote Access Tool) is an extremely powerful reverse shell, file server, and control plane using HTTPS reverse tunnels as a transport mechanism.
Stars: ✭ 34 (-40.35%)
Mutual labels:  freebsd
zImageOptimizer
Simple image optimizer for JPEG, PNG and GIF images on Linux, MacOS and FreeBSD.
Stars: ✭ 108 (+89.47%)
Mutual labels:  freebsd

ansible-sshjail

GitHub release

An Ansible connection plugin for remotely provisioning FreeBSD jails separately from their jailhost.

This works by SSHing to the jail host using the standard Ansible SSH connection, moving any files into the jail directory, and using jexec to execute commands in the scope of the jail.

Requirements

Control node (your workstation or deployment server):

  • Ansible 2.0 RC3+
  • Python 2.7

Jailhost:

  • FreeBSD
  • At least one configured jail
  • Python 2.7
  • SSH
  • sudo

Target jail:

  • Python 2.7

Installation

This is a "Connection Type Plugin", as outlined in the Ansible docs.

To install sshjail:

  1. Clone this repo.
  2. Copy or link sshjail.py to one of the supported locations:
  • /usr/share/ansible/plugins/connection_plugins/sshjail.py
  • path/to/your/toplevelplaybook/connection_plugins/sshjail.py

Usage

Using sshjail, each jail is its own inventory host, identified with a host name of jail@jailhost. You must also specify ansible_connection=sshjail.

  • jail is the name or hostname of the jail.
  • jailhost is the hostname or IP address of the jailhost.

Keep in mind that ezjail encourages creating jails with their hostname, which implicitly names the jail with underscores substituted for dashes and dots. For example, a jail created with ezjail-admin create test-jail 'em1|192.168.33.20', will have hostname test-jail and jail name test_jail. sshjail will accept either name in the ansible host specification.

Also note that FreeBSD pkgng places Python at /usr/local/bin/python2.7 by default. Make sure to specify this with the ansible_python_interpreter variable!

The following inventory entries are examples of using sshjail:

# bare minimum
[email protected] ansible_python_interpreter=/usr/local/bin/python2.7 ansible_connection=sshjail

# sample vagrant configuration
my-db-jail [email protected] ansible_ssh_port=2222 ansible_python_interpreter=/usr/local/bin/python2.7 ansible_connection=sshjail ansible_ssh_user=vagrant

Adding these hosts dynamically, like after freshly creating them via Ansible, or by iterating over jls output, can be done via the built-in add_host module:

- name: add my-db-jail to ansible inventory
  add_host: name=my-db-jail groups=jails
            ansible_ssh_host=my-db-jail@{{ansible_ssh_host}}
            ansible_ssh_port={{ansible_ssh_port}}
            ansible_python_interpreter=/usr/local/bin/python2.7
            ansible_connection=sshjail

A note about privileges

By default in FreeBSD, only root can enter jails. This means that when invoking ansible or ansible-playbook, you need to specify --become, and in a playbook, use become: yes/become_method: sudo. If sudo requires a password (shame on you if not, unless it's vagrant!), you'll need --ask-become-pass as well.

This means any commands executed by sshjail roughly translate to sudo jexec $jailName $command.

An alternative to requiring root access is to use the jailme utility. jailme is "a setuid version of jexec to allow normal users access to FreeBSD jails".

If you want to use jailme, you'll need to ensure it's installed on the jailhost, and specify the user to sudo as via --become-user on the command line, or become_user: username in a play or task. sshjail will prefer to use jailme if it's installed, whether you are sudoing as root or not.

This results in commands similar to sudo -u $becomeUser jailme $jailId $command.

Because of limitations of Ansible, this plugin cannot really do things like sudo jexec sudo -u myuser $command

Known Issues

  • None at the moment

Contributing

Let me know if you have any difficulties using this, by creating an issue.

Pull requests are always welcome! I'll try to get them reviewed in a timely manner.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].