Installation
Allgemein
- apt install python-pip
- python -m pip install ansible
Windowsunterstützung
Arbeitsverzeichnis
- mkdir ~/ansible
- cd ~/ansible
Ansible-Konfigurationsdatei
[defaults]
inventory = inventory
private_key_file = ~/.ssh/id_rsa
roles_path = $HOME/ansible/roles
Inventory
[cloud]
10.0.10.99
Ansible ping
10.0.10.99 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
---
- name: Install Apache2 on Ubuntu hosts
hosts: all
become: yes # Führt die Aufgaben mit Root-Rechten aus
tasks:
- name: Update apt cache
apt:
update_cache: yes
- name: Install Apache2
apt:
name: apache2
state: present
- name: Ensure Apache2 is running and enabled
service:
name: apache2
state: started
enabled: yes
Installation
- ansible-playbook install_apache.yml