Lab 1 - Solution¶
Mandatory¶
Check the infrastructure¶
Login on
srv.<firstname>.labasansibleusercheck the ansible version (2.x)
- try to connect to the other servers via ssh and accept the ssh host keys
web1.<firstname>.labweb2.<firstname>.labdb.<firstname>.lab
ansible --version
ssh web1.<firstname>.lab
ssh web2.<firstname>.lab
ssh db.<firstname>.lab
Git Installation¶
- Connect to your
srv.<firstname>.labasansibleuser - Switch to
rootviasudo - Install
git
ssh -l ansible srv.firstname.lab
sudo su -
apt-get install git
Create a git repo¶
- as
ansibleuser - create a local git repo in
/home/ansible/training - create a file e.g
README.mdand add it to your git repo - make your first git commit
- check the log
mkdir /home/ansible/training
cd /home/ansible/training
git init
vi README.md
git status
git add README.md
git commit -m 'first commit'
git log
Optional¶
Checkout a public repository¶
- switch into the
/tmpdirectory - clone the git remote repo (https://github.com/pstauffer/pstauffer.github.io.git)
- change the
README.mdfile - look at the differences
cd /tmp
# clone repo
git clone https://github.com/pstauffer/pstauffer.github.io.git
# edit readme
vi README.md
# print out the working tree status
git status
# print out the differences of the readme
git diff README.md