Skip to content

Commit e6ee109

Browse files
committed
Added 'src/network/roles.md'.
1 parent 07d5032 commit e6ee109

File tree

10 files changed

+362
-3
lines changed

10 files changed

+362
-3
lines changed

network_run/cisco_dns.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- name: configure cisco routers
3+
hosts: cisco-r1
4+
gather_facts: no
5+
vars:
6+
dns: "223.5.5.5 223.6.6.6"
7+
8+
tasks:
9+
- name: configure hostname
10+
cisco.ios.ios_config:
11+
lines: hostname {{ inventory_hostname }}
12+
13+
- name: configure DNS
14+
cisco.ios.ios_config:
15+
lines: ip name-server {{ dns }}

network_run/cisco_dns_refined.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
- name: configure cisco routers
3+
hosts: cisco-r1
4+
gather_facts: no
5+
6+
roles:
7+
- system_demo

network_run/cisco_dns_vars.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: configure cisco routers
3+
hosts: cisco-r1
4+
gather_facts: no
5+
6+
vars:
7+
dns: 8.8.8.8
8+
9+
roles:
10+
- system_demo

network_run/demo_cisco.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- hosts: cisco-r1
2+
gather_facts: no
3+
4+
tasks:
5+
- debug:
6+
msg: "test"

network_run/inventory.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ leafs:
44
ansible_host: 192.168.122.189
55
ansible_user: hector
66
ansible_network_os: vyos.vyos.vyos
7+
8+
cisco-r1:
9+
ansible_host: 192.168.122.69
10+
ansible_network_os: cisco.ios.ios
11+
ansible_ssh_user: hector
12+
ansible_network_cli_ssh_type: paramiko
13+
714
arista-sw:
815
ansible_host: 192.168.122.116
916
ansible_user: admin
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
dns: '223.5.5.5 223.6.6.6'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
- name: configure hostname
3+
cisco.ios.ios_config:
4+
lines: hostname {{ inventory_hostname }}
5+
6+
- name: configure DNS
7+
cisco.ios.ios_config:
8+
lines: ip name-server {{ dns }}

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@
172172
- [网络自动化有何不同?](network/difference.md)
173173
- [运行咱们的首个命令与 Playbook](network/initial.md)
174174
- [建立咱们的仓库](network/inventory.md)
175+
- [使用 Ansible 网络角色](network/roles.md)
175176

176177

177178
---

src/network/inventory.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ echo "my-ansible-vault-pw" > ~/my-ansible-vault-pw-file
133133
2. 创建出咱们 VyOS 网络设备的加密 ssh 密码,从咱们刚才创建的文件中拉取 `ansible-vault` 的密码:
134134

135135

136-
```console
136+
```yaml
137137
$ ansible-vault encrypt_string --encrypt-vault-id prod "my_password" --name "ansible_password"
138138
Encryption successful
139139
ansible_password: !vault |
@@ -148,7 +148,7 @@ ansible_password: !vault |
148148
> **译注**:`--encrypt-vault-id prod` 命令行参数使用了定义在 `~/.ansible.cfg` 配置设置中的变量。参见 [管理 vault 密码](../usage/vault/passwords.md)。
149149

150150
```ini
151-
vault_identity_list = 'dev@~/.ansible/dev.secret', 'prod@~/.ansible/prod.secret', 'default@~/.ansible/prod.secret', 'input@prompt'
151+
vault_identity_list = 'dev@~/.ansible/dev.secret', 'prod@~/.ansible/prod.secret', 'default@~/.ansible/prod.secret'
152152
```
153153

154154
> 使用命令 `openssl rand -base64 20 | sed -E 's/(.)\1+/\1/g' > ~/.ansible/prod.secret` 可产生高强度的随机 `ansible-vault` 密码。
@@ -195,7 +195,7 @@ vyos: # this is a group in yaml inventory, but you can also do under a host
195195
ansible-playbook -i network_run/inventory.yml --vault-id prod@~/.ansible/prod.secret src/network/demo_vault.yml
196196
```
197197

198-
> **译注**:在 `~/.ansible.cfg` 中设置了 `vualt_identity_list` 变量后,不加 `--vault-id` 也可以解密 vault 变量。且运行上面的命令会始终要求输入 Vualt 密码
198+
> **译注**:在 `~/.ansible.cfg` 中设置了 `vualt_identity_list` 变量后,不加 `--vault-id` 也可以解密 vault 变量。~~且运行上面的命令会始终要求输入 Vualt 密码~~。经测试,删除 `~/.ansible.cfg` 中变量 `vault_identity_list` 里的 `input@prompt` 后此现象消失。
199199

200200
```console
201201
$ ansible-playbook -i network_run/inventory.yml src/network/demo_vault.yml

0 commit comments

Comments
 (0)