Difference between revisions of "IT-SDK-Ansible"
Jump to navigation
Jump to search
Samerhijazi (talk | contribs) (→Playbook) |
Samerhijazi (talk | contribs) (→Inventory) |
||
| Line 10: | Line 10: | ||
=Inventory= | =Inventory= | ||
| − | * | + | * Lists which hosts will receive commands from the control host. |
| − | * | + | * Location for the inventory file: /etc/ansible/hosts |
| − | |||
<pre class="code"> | <pre class="code"> | ||
ansible all --list-hosts | ansible all --list-hosts | ||
| − | + | nano inventory | |
| + | ------------------------------ | ||
| + | [webservers] | ||
| + | 192.0.2.0 | ||
| + | 192.0.2.1 | ||
| + | [databases] | ||
| + | 192.0.2.3 ansible_user=root | ||
| + | ------------------------------ | ||
</pre> | </pre> | ||
Revision as of 14:39, 31 July 2021
Contents
Ref.
- https://docs.ansible.com/ansible/latest/collections/all_plugins.html
- https://www.redhat.com/de/services/training/do007-ansible-essentials-simplicity-automation-technical-overview?sc_cid=701f2000001OQFsAAO
Notes
- Ansible: playbooks, roles, variables, basic modules
Commands
ansible-playbook playbook.yml ## execute the playbook
Inventory
- Lists which hosts will receive commands from the control host.
- Location for the inventory file: /etc/ansible/hosts
ansible all --list-hosts nano inventory ------------------------------ [webservers] 192.0.2.0 192.0.2.1 [databases] 192.0.2.3 ansible_user=root ------------------------------
Playbook
# Play 1
---
- name: this playbook will install httpd ## Name of the Play
hosts: web ## In which Node shall the play done
vars: ## Definition von Variables
pkgname: httpd
tasks: ## Tasks in this play
- name: Install latest of Apache ## Name of the Task
become: ture ## Execute this Task as "sudo dnf install httpd"
become_user: weblogic ## Exceute this task as "sudo -u weblogic dnf install httpd"
dnf: ## Name of the Modul used (etc. command, apt, user, service )
name: {{ pkgname }} ## Parameter used form modul
state: latest ## Parameter used form modul