A little project to start learning ansible. This project contains a
playbook to set up gitolite on a server (like amor
and code
).
This project would currently work perfectly for code
, which
already has git
set up.
To support amor
(which has gcc
installed), we would additionally
need to get git working.
sudo apt install ansible ansible-lint vagrant
vagrant up
vagrant ssh-config
IP is dynamic, user is vagrant
vagrant ssh sudo -s apt install git adduser robertsw logout
ssh-copy-id -i ~/.ssh/id_rsa.pub robertsw@192.168.121.71
vagrant destroy
To test gcc building of git:
apt install build-essential libz-dev gettext
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.xz
http://www.brianlinkletter.com/installing-debian-linux-in-a-virtualbox-virtual-machine/
setup
hostname: amor2 root pwd: root user: robertsw pwd: Queens
install only ssh server and standard system utilities
stop machine
virtualbox: network settings Open Tab: Adapter 1 Enable the Adapter and select “NAT” Open Tab: Adapter 2 Enable the adapter and select: “Host-only Adapter” Select Name: “VirtualBox Host-only Ethernet Adapter” Click at “Extended” Select the adapter: “Intel PRO/1000 MT Desktop…” Select the modus: “Allow all and host” Click on “Ok” to save all settings.
start machine, log in as root
apt install net-tools git ifconfig
nano /etc/network/interfaces, add lines:
allow-hotplug enp0s8 iface enp0s8 inet dhcp
reboot the machine, log in as root, ifconfig
IP 192.168.99.100
log out, from terminal:
ssh-copy-id -i ~/.ssh/id_rsa.pub robertsw@192.168.99.100
then ansible –list all should work
Run the playbook:
$ ansible-playbook amor2.yml PLAY [all] ********************************************************************* TASK [Gathering Facts] ********************************************************* ok: [192.168.99.100] TASK [Create local directory] ************************************************** ok: [192.168.99.100] => (item=.gitolite/logs) ok: [192.168.99.100] => (item=.ssh) changed: [192.168.99.100] => (item=local/src) changed: [192.168.99.100] => (item=local/bin) TASK [Download and extract gitolite release] *********************************** changed: [192.168.99.100] TASK [Install gitolite] ******************************************************** changed: [192.168.99.100] TASK [Copy public key] ********************************************************* changed: [192.168.99.100] TASK [Setup gitolite] ********************************************************** changed: [192.168.99.100] PLAY RECAP ********************************************************************* 192.168.99.100 : ok=6 changed=5 unreachable=0 failed=0
After that, we can access the gitolite using our gitolite SSH key:
$ ssh -i ~/.ssh/gitolite_rsa.pub robertsw@192.168.99.100 PTY allocation request failed on channel 0 hello gitolite_rsa, this is robertsw@amor2 running gitolite3 (unknown) on git 2.20.1 R W gitolite-admin R W testing Connection to 192.168.99.100 closed.
We can also verify that paths are set up and repos are visible to gitolite on the command line:
$ ansible -m shell -a "local/bin/gitolite list-repos" all 192.168.99.100 | SUCCESS | rc=0 >> gitolite-admin testing
doesn’t work?: docker run -d debian:stretch –init –name amor2