

/bin/echo '$1$rtd8Ub7R$5Ohzuy8WXlkaK9cA2T1wb0' | pw usermod root -H 0
cat >> /etc/rc.conf <<EOF
hostname="snapshot-ipv4-dhcp-el7"
sshd_enable="YES"
ntpd_enable="YES"
EOF

echo ifconfig_`ifconfig -l | cut -d ' ' -f 1`=DHCP >>/etc/rc.conf

echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config

/bin/hostname snapshot-ipv4-dhcp-el7
cp /usr/share/zoneinfo/UTC /etc/localtime
adjkerntz -a
ntpdate 0.freebsd.pool.ntp.org

mkdir /root/install/
freebsd-update fetch > /root/install/freebsd-update_fetch.txt
freebsd-update install > /root/install/freebsd-update_install.txt

env ASSUME_ALWAYS_YES=YES pkg bootstrap
pkg update > /root/install/pkg_update.txt
pkg upgrade -y > /root/install/pkg_upgrade.txt


if [ -f /usr/bin/dnf ]; then
  dnf -y install puppet
else
  yum -t -y install puppet
fi

cat > /etc/puppet/puppet.conf << EOF
[main]
vardir = /var/lib/puppet
logdir = /var/log/puppet
rundir = /var/run/puppet
ssldir = \$vardir/ssl

[agent]
pluginsync      = true
report          = true
certname        = snapshot-ipv4-dhcp-el7

EOF


puppet_unit=puppet
/usr/bin/systemctl list-unit-files | grep -q puppetagent && puppet_unit=puppetagent
/usr/bin/systemctl enable ${puppet_unit}

# export a custom fact called 'is_installer' to allow detection of the installer environment in Puppet modules
export FACTER_is_installer=true
# passing a non-existent tag like "no_such_tag" to the puppet agent only initializes the node
/usr/bin/puppet agent --config /etc/puppet/puppet.conf --onetime --tags no_such_tag  --no-daemonize



# SSH keys setup snippet for Remote Execution plugin
#
# Parameters:
#
# remote_execution_ssh_keys: public keys to be put in ~/.ssh/authorized_keys
#
# remote_execution_ssh_user: user for which remote_execution_ssh_keys will be
#                            authorized
#
# remote_execution_create_user: create user if it not already existing
#
# remote_execution_effective_user_method: method to switch from ssh user to
#                                         effective user
#
# This template sets up SSH keys in any host so that as long as your public
# SSH key is in remote_execution_ssh_keys, you can SSH into a host. This
# works in combination with Remote Execution plugin by querying smart proxies
# to build an array.
#
# To use this snippet without the plugin provide the SSH keys as host parameter
# remote_execution_ssh_keys. It expects the same format like the authorized_keys
# file.




PATH=/usr/bin:/usr/sbin:/bin:/sbin:$PATH shutdown -r +1

exit 0
