This commit is contained in:
Casual 2024-06-11 01:56:36 +03:00
parent 95167c7d2f
commit cafd9f6b30

View File

@ -118,7 +118,7 @@ Example output:
}
}
```
3. Chech that all hosts accessable by ansible - `ansible all -m ping -i inventory.ini`
3. Check that all hosts accessable by ansible - `ansible all -m ping -i inventory.ini`
```sh
192.168.0.13 | UNREACHABLE! => {
"changed": false,
@ -167,13 +167,13 @@ As you can see, we have `UNREACHABLE!` host - it's router and we can't access it
[all:vars]
ansible_user=ssh_connect_user #SSH user to connect
```
If we would have many hosts in `routers` we would use solution 3, but we can use solution 2.
Run `ansible all -m ping -i inventory.ini` again
If we would have many hosts in `routers` we would use solution 3, but we can use solution 2.
Run `ansible all -m ping -i inventory.ini` again
If you still get `Permission denied` - then you forgot to `ssh-copy-id vyos@192.168.0.13`
3. Create `playbook.yaml`
We will start with easiest task - dump config from router.
We will start with easiest task - dump config from router.
`playbook.yaml`:
```yaml
- name: dump config from router
@ -187,9 +187,9 @@ We will start with easiest task - dump config from router.
filename: ./backup.cfg
```
All `.yaml` files uses `YAML` so exact number of spaces IS IMPORTANT
All `.yaml` files uses `YAML` so exact number of spaces IS IMPORTANT
Then run playbook - `ansible-playbook -i inventory.ini playbook.yaml`
Then run playbook - `ansible-playbook -i inventory.ini playbook.yaml`
```sh
PLAY [dump config from router] **************************************************************
@ -236,12 +236,12 @@ ansibleExample ➤ cat backup.cfg
set interfaces ethernet eth1 address 'dhcp'
...
```
We successfully backuped config!
We successfully backuped config!
But where did I found `vyos.vyos.vyos_config` and its parameters?
__Search in [Ansible Docs](https://docs.ansible.com/ansible/latest/index.html) or Google.__
But where did I found `vyos.vyos.vyos_config` and its parameters?
__Search in [Ansible Docs](https://docs.ansible.com/ansible/latest/index.html) or Google.__
4. Create role for PCs - `mkdir roles; cd roles; ansible-galaxy init [Name]`
4. Create role for PCs - `mkdir roles; cd roles; ansible-galaxy init [Name]`
5. Edit `playbook.yaml`
`playbook.yaml`:
@ -277,7 +277,7 @@ PLAY RECAP *********************************************************************
192.168.0.5 : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
```
Everything fine.
Everything fine.
6. Edit role's tasks - `roles/web-browser/tasks/main.yml`:
```yaml