diff --git a/lxc_erstes_beispiel.md b/lxc_erstes_beispiel.md new file mode 100644 index 0000000..01ca72b --- /dev/null +++ b/lxc_erstes_beispiel.md @@ -0,0 +1,82 @@ +## Verwendete Kommandos + +Erstellen der LXC-Maschine foo + +```bash +sudo lxc-create --name foo --template ubuntu +sudo lxc-start --name foo +sudo lxc-ls +sudo lxc-ls --help +sudo lxc-ls --fancy +``` + +Mit der IP kann man sich via ssh einlogen: + +``` +ssh ubuntu@10.0.3.110 +sudo lxc-create --name baa --template ubuntu +sudo lxc-start --name baa +sudo lxc-ls --fancy +nmap 10.0.3.0/24 +whatis nmap +ssh ubuntu@10.0.3.110 +dig @10.0.3.1 foo +ping -c 4 10.0.3.110 +ping -c 4 10.0.3.55 +dig @10.0.3.1 foo +sudo lxc-ls -f +``` + +Ansible mit Inventory-Datei + +```bash +ansible --version +cd ~/ansible_lxc_bsa2/ +vi inventory +cat inventory +[lokal] +localhost ansible_connection=local +``` + +```bash +ansible --inventory inventory -m ping +ansible -i inventory -m ping lokal +``` + +```bash +sudo lxc-ls --fancy +vi inventory +cat inventory +[lokal] +localhost ansible_connection=local + +[notme] +10.0.3.110 +10.0.3.55 +``` + +```bash +ansible -i inventory -m ping notme +vi inventory +cat inventory +[lokal] +localhost ansible_connection=local + +[notme] +10.0.3.110 ansible_user=ubuntu +10.0.3.55 ansible_user=ubuntu +``` +```bash +ansible -i inventory -m ping notme +vi inventory +cat inventory +[lokal] +localhost ansible_connection=local + +[notme] +10.0.3.110 ansible_user=ubuntu ansible_password=ubuntu +10.0.3.55 ansible_user=ubuntu ansible_password=ubuntu + +ansible -i inventory -m ping notme +ansible -i inventory -m ping all +```