📘Cisco DevNet Associate (200-901 DEVASC)
1. What is Ansible?
Ansible is an automation tool used to configure systems, deploy applications, and manage infrastructure.
It works by executing instructions written in playbooks.
Key Characteristics of Ansible
- Agentless (no software needed on target devices)
- Uses SSH for communication
- Written in YAML
- Uses reusable modules
- Works with servers, network devices, and cloud infrastructure
In DevNet environments, Ansible helps automate network configuration, server configuration, and service management.
2. What is an Ansible Playbook?
An Ansible playbook is a file written in YAML format that contains a set of automation tasks.
A playbook defines:
- Which systems to configure
- What tasks should be executed
- In what order the tasks run
Example Structure of a Playbook
---
- name: Configure Web Server
hosts: webservers
become: yes tasks:
- name: Install Apache
apt:
name: apache2
state: present
Main Components
| Component | Description |
|---|---|
| Hosts | Target systems where tasks will run |
| Tasks | Individual automation steps |
| Modules | Built-in tools that perform actions |
| Variables | Store reusable values |
| Handlers | Triggered actions after changes |
A playbook typically represents a complete workflow for configuring a system.
3. Understanding Automation Workflow in Ansible
An automation workflow is a sequence of steps performed automatically.
A typical IT workflow might include:
- Install required packages
- Create or manage users
- Configure services
- Start or stop services
These steps are defined in an Ansible playbook and executed in order.
For the DEVASC exam, you should be able to identify these workflow steps in a playbook.
4. Workflow Step 1 — Managing Packages
Package management is one of the most common automation tasks.
Packages are software components installed on a system such as:
- Web servers
- Database software
- Monitoring tools
- Networking tools
Ansible automates package installation, removal, and updates.
Common Package Modules
| Module | System Type |
|---|---|
apt | Debian/Ubuntu systems |
yum | RedHat/CentOS |
dnf | Fedora |
package | Generic package manager |
Example: Installing a Package
- name: Install Nginx
apt:
name: nginx
state: present
What This Task Does
- Connects to the server
- Checks if nginx is installed
- Installs it if missing
This ensures the desired state of the system.
Example: Removing a Package
- name: Remove Apache
apt:
name: apache2
state: absent
This removes unwanted software automatically.
Why Package Management is Important
In IT environments:
- Hundreds of servers require the same software
- Manual installation takes time
- Automation ensures consistent software versions
5. Workflow Step 2 — User Management Related to Services
Services often require specific users to run them securely.
Examples include:
- Web service accounts
- Database service users
- Monitoring users
Ansible can automate user management.
User Management Tasks
Typical tasks include:
- Creating users
- Deleting users
- Managing passwords
- Assigning permissions
- Adding users to groups
Example: Creating a User
- name: Create service user
user:
name: webadmin
state: present
What Happens
The playbook:
- Checks if the user exists
- Creates the user if not present
Example: Adding a User to a Group
- name: Add user to group
user:
name: webadmin
groups: www-data
append: yes
This allows the user to manage web services.
Why User Management is Automated
In large environments:
- Systems must follow security policies
- Service users must have correct permissions
- Automation ensures consistent access control
6. Workflow Step 3 — Basic Service Configuration
After installing software, it must be configured.
Configuration defines:
- Ports used by the service
- File locations
- Security settings
- Service parameters
Ansible can automatically configure these settings.
Methods for Configuration
Ansible uses several modules:
| Module | Purpose |
|---|---|
copy | Copy configuration files |
template | Create dynamic configuration files |
lineinfile | Modify specific lines in files |
blockinfile | Insert blocks of configuration |
Example: Copy Configuration File
- name: Deploy configuration file
copy:
src: nginx.conf
dest: /etc/nginx/nginx.conf
This task:
- Takes a configuration file from the automation server
- Copies it to the target system
- Replaces the existing configuration
Example: Modify Configuration
- name: Set service port
lineinfile:
path: /etc/app/config.conf
line: "port=8080"
This ensures the service runs on the correct port.
Why Configuration Automation is Important
Without automation:
- Administrators manually edit configuration files
- Mistakes can occur
- Systems become inconsistent
Automation guarantees identical configurations across systems.
7. Workflow Step 4 — Starting and Stopping Services
After installation and configuration, services must be controlled.
Services may need to:
- Start
- Stop
- Restart
- Reload
Ansible automates these actions.
Service Management Module
The most common module is:
service
or
systemd
Example: Start a Service
- name: Start nginx service
service:
name: nginx
state: started
This ensures the service is running.
Example: Stop a Service
- name: Stop nginx service
service:
name: nginx
state: stopped
Example: Restart a Service
- name: Restart nginx service
service:
name: nginx
state: restarted
Example: Enable Service on Boot
- name: Enable service
service:
name: nginx
enabled: yes
This ensures the service starts automatically when the system boots.
8. Example of a Complete Automation Workflow
A typical Ansible playbook might automate the full process.
Example Workflow
---
- name: Configure Web Service
hosts: servers
become: yes tasks: - name: Install nginx
apt:
name: nginx
state: present - name: Create service user
user:
name: webadmin
state: present - name: Deploy configuration
copy:
src: nginx.conf
dest: /etc/nginx/nginx.conf - name: Start nginx service
service:
name: nginx
state: started
Workflow Steps
- Install required package
- Create user account
- Deploy configuration file
- Start the service
This represents a complete automated infrastructure setup.
9. Order of Tasks in Automation
Ansible runs tasks in sequence.
Typical workflow order:
1️⃣ Install packages
2️⃣ Configure users
3️⃣ Configure services
4️⃣ Start or restart services
Correct ordering ensures the system works properly.
Example:
- A service cannot start before it is installed.
- Configuration cannot apply if the software is missing.
10. Idempotency in Ansible Workflows
Ansible follows the concept of idempotency.
This means:
Running the playbook multiple times produces the same result.
Example:
- If nginx is already installed, Ansible will not reinstall it
- If a user already exists, Ansible skips creation
Benefits:
- Safe automation
- No duplicate actions
- Consistent infrastructure
11. Recognizing Ansible Workflow in the DEVASC Exam
In the exam, you may see:
- A playbook snippet
- YAML code
- Automation steps
You must identify what workflow is being automated.
Look for these key elements:
| Playbook Task | Workflow Step |
|---|---|
apt / yum | Package management |
user | User management |
copy / template | Configuration deployment |
service / systemd | Start/stop services |
Understanding these modules helps you recognize the automation process.
12. Key Points to Remember for the Exam
Important Concepts
✔ Ansible automates infrastructure tasks
✔ Playbooks define automation workflows
✔ Tasks run sequentially
✔ Modules perform specific actions
Core Workflow Steps
- Package Management
- Install/remove software
- User Management
- Create service users
- Manage groups and permissions
- Basic Service Configuration
- Deploy configuration files
- Modify settings
- Service Control
- Start/stop/restart services
- Enable services on boot
Most Important Ansible Modules
| Module | Purpose |
|---|---|
apt, yum, dnf | Manage packages |
user | Manage user accounts |
copy | Copy files |
template | Create dynamic configuration files |
lineinfile | Modify configuration lines |
service | Manage services |
Final Summary
In the Cisco DevNet Associate (200-901 DEVASC) exam, you must understand how Ansible playbooks automate IT workflows.
A typical automated workflow includes:
- Installing required software packages
- Managing service-related users and permissions
- Configuring service settings
- Starting, stopping, or restarting services
These tasks are written in YAML playbooks and executed automatically by Ansible.
Understanding how these steps appear in a playbook helps you identify automation workflows, which is an important exam objective.
