티스토리 뷰
반응형
nxis, ios 구분을 인벤토리에서 구분하여 when조건으로 실행 한다.
hosts - inventory
[network:children]
nxos
ios
[nxos]
nxos01 ansible_host=10.60.50.13
[nxos:vars]
ansible_connection=network_cli
ansible_network_os=nxos
ansible_user=fendys
ansible_password=password1!
[ios]
ios01 ansible_host=10.6.99.176
ios01 ansible_host=10.3.99.145
[ios:vars]
ansible_connection=network_cli
ansible_network_os=ios
ansible_user=fendys
ansible_password=password1!
#ansible_become=yes
#ansible_authorize=yes
#ansible_become_method=enable
#ansible_become_password=password2!
play-book - role type
---
## fendys@tistory.com
## use : ansible-playbook network_work.yml --ask-vault-pass
- hosts: network
gather_facts: false
become: false
roles:
- { role : nxos, tags: ["reinstall"] }
- { role : ios, tags: ["reinstall"] }
ios role - ios cli
## ansible/role/ios/tasks/main.yml
---
- name: check ios version
ios_command:
commands: show version
register: REGI_iosversion
when: ansible_network_os == 'ios'
- name: check ios running-config
ios_command:
commands: show running-config view full
register: REGI_iosrun
when: ansible_network_os == 'ios'
- name: save version
shell: echo "{{ REGI_iosversion.stdout | join() }}" > /etc/ansible/result/network-config/$(date +'%Y-%m-%d')-{{ inventory_hostname }}-ios-version.log
delegate_to: localhost
when: ansible_network_os == 'ios'
- name: save version
shell: echo "{{ REGI_iosrun.stdout | join() }}" > /etc/ansible/result/network-config/$(date +'%Y-%m-%d')-{{ inventory_hostname }}-ios-running-config.log
delegate_to: localhost
when: ansible_network_os == 'ios'
nxos role - nxos cli
---
- name: check version
nxos_command:
commands: show version
register: REGI_version
when: ansible_network_os == 'nxos'
- name: check nxos running-config
nxos_command:
commands: show running-config
register: REGI_run
when: ansible_network_os == 'nxos'
- name: save version
shell: echo "{{ REGI_version.stdout | join() }}" > /etc/ansible/result/network-config/$(date +'%Y-%m-%d')-{{ inventory_hostname | join() }}-nxos-version.log
delegate_to: localhost
when: ansible_network_os == 'nxos'
- name: save username
shell: echo "{{ REGI_run.stdout | join() }}" > /etc/ansible/result/network-config/$(date +'%Y-%m-%d')-{{ inventory_hostname | join() }}-nxos-running-config.log
delegate_to: localhost
when: ansible_network_os == 'nxos'
반응형
'ansible' 카테고리의 다른 글
ansible remote shell (0) | 2023.08.31 |
---|---|
cisco switch config backup (0) | 2022.02.28 |
install ansible on centos 7 (0) | 2021.10.26 |
ansible 간단 명령어 (0) | 2021.08.18 |
ansible key copy (0) | 2021.08.05 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- ansible ios
- 윈도우서버 계정 관려
- ansible network
- 리눅스 커맨드 로그남기기
- kernel 변경
- cisco ansible
- 특정 라인삭제
- dl20 centos7
- ISCSI 볼륨 RAC
- ios ansible
- centos7 ntp
- cmd로 계정 생성
- dl20 g9 centos7 설치
- cgroup
- DL20 GEN9 장비에 CentOS 7
- linux command log
- oracle linux8 kernel
- vm rac
- nxos ansible
- nutanix rac
- ipmi
- 특정 문구 치환
- windows.old 강제삭제
- dl20
- ILO
- 윈도우 cmd 계정 관리
- cmd로 윈도우 계정 관리
- chrony
- shell connmad log
- CentOS 7 GUI
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함