تهيئة الشبكة باستخدام Ansible
انتقل من البرامج النصية الإجرائية إلى الأتمتة التصريحية: استخدم أدلة Ansible لتهيئة أجهزة الشبكة ومضيفي Linux وإدارتهم على نطاق واسع.
تهيئة الشبكة باستخدام Ansible درس مجاني في Linux Networking & TCP/IP for Developers على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Linux Networking & TCP/IP for Developers، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Linux Networking & TCP/IP for Developers 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Why Declarative Automation
Bash and Python scripts describe how to do something step by step. Ansible describes the desired state and converges hosts toward it.
This is idempotent: running the same playbook twice leaves the system in the same correct state.
Agentless by Design
Ansible needs no agent on managed hosts. It connects over SSH (or network device APIs) and pushes changes, making it easy to adopt across a fleet.
The Inventory
The inventory lists the hosts you manage, grouped logically. Below is a simple INI inventory.
[routers]
rtr1 ansible_host=10.0.0.1
rtr2 ansible_host=10.0.0.2
[switches]
sw1 ansible_host=10.0.1.1Ad-Hoc Commands
For quick one-off tasks, run a module directly without a playbook. This pings all hosts in a group.
ansible routers -m pingYour First Playbook
A playbook is a YAML file describing tasks. Each task invokes a module with parameters.
- hosts: switches
tasks:
- name: Ensure NTP is installed
apt:
name: ntp
state: presentVariables and Templates
Variables parameterize playbooks. The template module renders Jinja2 files, perfect for generating per-device config from one source of truth.
- name: Render interface config
template:
src: iface.j2
dest: /etc/network/interfacesNetwork Device Modules
Ansible ships vendor collections (e.g. cisco.ios, arista.eos) that speak each platform's CLI or API to push configuration.
- name: Configure interface
cisco.ios.ios_config:
lines:
- description Uplink
- ip address 10.0.0.1 255.255.255.0
parents: interface GigabitEthernet0/1Handlers
Handlers run only when notified by a changed task — ideal for restarting a service or saving a device config exactly once after changes.
handlers:
- name: save config
cisco.ios.ios_config:
save_when: alwaysCheck Mode (Dry Run)
Run any playbook with --check to preview changes without applying them — a safe way to validate before touching production.
ansible-playbook site.yml --check --diffRoles for Reuse
Roles package tasks, templates, and variables into reusable units. A base-network role can be applied to every device for consistent baseline config.
- hosts: all
roles:
- base-network
- monitoringSecuring Secrets with Vault
Never store passwords in plaintext. ansible-vault encrypts sensitive variables, keeping credentials safe in version control.
ansible-vault encrypt group_vars/routers/secrets.ymlQuick Check
Test your Ansible understanding.
Recap
You can now automate declaratively with Ansible:
- Agentless, idempotent state management
- Inventories, playbooks, and variables
- Vendor network modules and Jinja2 templates
- Handlers, roles, and
--checkdry runs - Encrypt secrets with
ansible-vault
This extends your Bash, Python, and REST API automation lessons to fleet scale.
تعلم Linux Networking & TCP/IP for Developers مع معلم ذكاء اصطناعي — مجانًا
اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.
- الدورات
- 12
- الدروس
- 48
الأسئلة الشائعة
هل درس «تهيئة الشبكة باستخدام Ansible» مجاني؟
نعم — نص درس «تهيئة الشبكة باستخدام Ansible» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Linux Networking & TCP/IP for Developers، انتقل إلى CoddyKit PRO. تتضمن دورة Linux Networking & TCP/IP for Developers 4 دروس في المجموع.
ماذا ستتعلم في «تهيئة الشبكة باستخدام Ansible»؟
انتقل من البرامج النصية الإجرائية إلى الأتمتة التصريحية: استخدم أدلة Ansible لتهيئة أجهزة الشبكة ومضيفي Linux وإدارتهم على نطاق واسع. تتمرن على Linux Networking & TCP/IP for Developers مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Linux Networking & TCP/IP for Developers؟
لا تُشترط خبرة سابقة. Linux Networking & TCP/IP for Developers على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «تهيئة الشبكة باستخدام Ansible»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Linux Networking & TCP/IP for Developers هذا؟
نعم. كل درس في Linux Networking & TCP/IP for Developers يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- برمجة Bash النصية للشبكات
- Python لأتمتة الشبكات
- واجهات REST API لأجهزة الشبكة
- تهيئة الشبكة باستخدام Ansible