Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 티스토리챌린지
- 오블완
- BPDU
- ansible playbook
- gns3
- 프로그래머스
- Packet Tracer
- pagp
- freeradius
- 네이티브 vlan
- 네트워크
- Red Hat
- Network Design
- centos
- eigrp
- 네트워크 설계
- Ansible
- 방화벽
- 하프오픈
- stream 9
- LACP
- vlan
- ospf
- STP
- junos os
- port aggregation protocol
- SQL
- rommon mode
- pvst+
- Cisco
Archives
- Today
- Total
Doctor Pepper
[Ansible] CML을 이용한 Ansible 구축 본문
728x90
1. CML 네트워크 구축

2. Ansible 구축(CentOS Stream 9)
- 의존성 Update
sudo dnf update -y |

- EPEL(Extra Packages for Enterprise Linux) 저장소 설치
sudo dnf install epel-release -y |

- Python3 및 pip 설치
sudo dnf install -y python3 python3-pip sudo pip3 install --upgrade pip setuptools |

- Ansible 및 Ansible Galaxy 컬렉션 설치
sudo dnf install -y ansible ansible-galaxy collection install cisco.ios ansible.netcommon |

- Ansible 관련 추가 라이브러리 설치
pip3 install ansible-pylibssh pip3 install paramiko |
- ansible-core 설치
pip install --upgrade ansible-core |
3. SSH 설정
- CentOS에 공개 키 및 정책 설정
ssh-keygen -t rsa -b 2048 |

update-crypto-policies --set LEGACY |

4. 네트워크 장비에 SSH 설정
# usern cisco pas cisco # usern cisco priv 15 # lin vty 0 4 # tr i a # logi loc # exit # ip domain-n automation.com # cry key gen rsa # 2048 |
5. 공개 키 복사 및 접속
- 공개 키 복사
ssh-copy-id -i ~/.ssh/id_rsa.pub cisco@203.230.7.1 |

- SSH 접속
ssh cisco@203.230.7.1 |

6. Ansible 파일 구성 및 실행
- Inventory 파일 : /etc/ansible/hosts
[routers] Router1 ansible_host=203.230.7.1 ansible_user=cisco ansible_password=cisco ansible_network_os=ios ansible_connection=network_cli Router2 ansible_host=203.230.8.2 ansible_user=cisco ansible_password=cisco ansible_network_os=ios ansible_connection=network_cli |
- Python 인터프리터 경로 추가
[routers:vars] ansible_python_interpreter=/usr/libexec/platform-python |
- Playbook 작성(check_interfaces.yml)
- name: Check Cisco interfaces hosts: routers gather_facts: no tasks: - name: Run "show ip int bri" ios_command: commands: - show ip int bri register: interface_output - name: Display output debug: var: interface_output.stdout_lines |
- Ansible Playbook 실행
ansible-playbook -i /etc/ansible/hosts check_interfaces.yml |

728x90
'Network 심화 > Ansible' 카테고리의 다른 글
[Ansible] 실제 장비를 이용한 Ansible 구축 (1) | 2025.03.27 |
---|---|
[Ansible] 대상 호스트 선정 (0) | 2024.12.22 |
[Ansible] Ansible 구성하기 (1) | 2024.12.09 |
[Ansible] 커뮤니티 앤서블과 레드햇 앤서블 (4) | 2024.12.09 |
[Ansible] Ansible 개념 (0) | 2024.12.09 |