Ansible Install: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| (4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
=Installation= | =Installation= | ||
==Allgemein== | ==Allgemein== | ||
| + | *apt install python-pip | ||
*python -m pip install ansible | *python -m pip install ansible | ||
| + | |||
==Windowsunterstützung== | ==Windowsunterstützung== | ||
*pip3 install pywinrm | *pip3 install pywinrm | ||
| Zeile 13: | Zeile 15: | ||
private_key_file = ~/.ssh/id_rsa | private_key_file = ~/.ssh/id_rsa | ||
roles_path = $HOME/ansible/roles | roles_path = $HOME/ansible/roles | ||
| + | =Inventory= | ||
| + | *cat inventory | ||
| + | [cloud] | ||
| + | 10.0.10.79 | ||
| + | |||
| + | =Ansible ping= | ||
| + | *ansible all -m ping | ||
| + | <pre> | ||
| + | 10.0.10.99 | SUCCESS => { | ||
| + | "ansible_facts": { | ||
| + | "discovered_interpreter_python": "/usr/bin/python3" | ||
| + | }, | ||
| + | "changed": false, | ||
| + | "ping": "pong" | ||
| + | } | ||
| + | </pre> | ||
| + | =Konfiguration= | ||
| + | *cat install_apache.yml | ||
| + | <pre> | ||
| + | --- | ||
| + | - 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 | ||
| + | </pre> | ||
| + | |||
| + | =Installation= | ||
| + | *ansible-playbook install_apache.yml | ||
Aktuelle Version vom 12. September 2024, 06:43 Uhr
Installation
Allgemein
- apt install python-pip
- python -m pip install ansible
Windowsunterstützung
- pip3 install pywinrm
Arbeitsverzeichnis
- mkdir ~/ansible
- cd ~/ansible
Ansible-Konfigurationsdatei
- cat ansible.cfg
[defaults] inventory = inventory private_key_file = ~/.ssh/id_rsa roles_path = $HOME/ansible/roles
Inventory
- cat inventory
[cloud] 10.0.10.79
Ansible ping
- ansible all -m ping
10.0.10.99 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
Konfiguration
- cat install_apache.yml
---
- 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