Introduction
Welcome to the Ansible Projects website. Here you'll find resources and guides on installing, running, and creating playbooks with Ansible.
How to Install Ansible
Follow these steps to install Ansible on your system:
sudo apt update sudo apt install ansible
For other operating systems, please refer to the official Ansible installation guide.
How to Run Ansible
To run Ansible, you need to create an inventory file and a playbook. Here's an example:
# inventory file (hosts) [webservers] 192.168.1.1 192.168.1.2 # playbook file (site.yml) - name: Ensure Apache is installed hosts: webservers tasks: - name: Install Apache apt: name: apache2 state: present
Run the playbook with the following command:
ansible-playbook -i hosts site.yml
Example Playbooks
Here are some example Ansible playbooks:
# playbook to update all packages - name: Update all packages hosts: all tasks: - name: Update packages apt: upgrade: dist
# playbook to create a new user - name: Create a new user hosts: all tasks: - name: Add user user: name: john state: present