Skip to content

Instantly share code, notes, and snippets.

@jpmens jpmens/ansi-bootstrap.sh Secret

Created Dec 12, 2019
Embed
What would you like to do?
bootstrap shell script for Ansible iocage training jail template
#!/bin/sh
# ansi-bootstrap.sh (C)2019 by Jan-Piet Mens <jp@mens.de>
# use to populate an iocage template for Ansible trainings
# (a.k.a. t-ansible0 builder)
set -e
export ASSUME_ALWAYS_YES=yes # for pkg
echo PermitRootLogin yes >> /etc/ssh/sshd_config # training jails
# set up "dhl" repository
mkdir -p /usr/local/etc/pkg/repos/
cat <<EOF1 > /usr/local/etc/pkg/repos/FreeBSD.conf
FreeBSD: { enabled: no }
DHL: { url: http://dhl.ansible.example:80/repo,
enabled: yes,
signature_type: none }
EOF1
pkg bootstrap
# it's BSD: the Standard Unix editor is already there, of course.
pkg install bash sudo vim-console git-lite \
ca_root_nss python36 \
bind-tools \
editors/mg editors/nano editors/pico-alpine editors/joe \
figlet
# Create "ansible" user and set root password for training
echo ansible | pw useradd ansible -u 2001 -c "Ansible user" -d /home/ansible \
-s /usr/local/bin/bash -h 0 -m
echo ansible | pw usermod root -h 0 -s /usr/local/bin/bash
# System
sysrc sshd_enable="YES"
truncate -s 0 /var/log/ansible
printf 'user.debug\t\t\t/var/log/ansible\n' > /etc/syslog.d/ansible.conf
pkg clean -a
rm -f ~ansible/.bash_history ~root/.bash_history
rm -f /tmp/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.