Unterricht mit lxc foo und baa und ansible inventory eingefügt

Michael Schaar 2023-09-21 13:35:40 +02:00
parent b638594ec9
commit a157aa10e2
1 changed files with 82 additions and 0 deletions

82
lxc_erstes_beispiel.md Normal file

@ -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
```