ansible:playbooks
Table of Contents
Playbooks
notepad++ installation
---
- name: Notepad++ installation Playbook
hosts: win_domain
tasks:
- name: Installing Notepad++
win_package:
path: '\\path\npp.7.9.5.Installer.x64.exe'
arguments: '/S'
product_id: 'Notepad++'
creates_version: '7.95'
creates_path: 'C:\Program Files\Notepad++\notepad++.exe'
state: present
when: ansible_os_family == 'Windows'
per richiamare un playbook:
ansible-playbook playbook.yml
oppure per diventare sudoers:
ansible-playbook -b playbook.yml
Upgrade Linux Various Distribution
Create a file hosts named hosts inside the worikng directory the file hosts contain, for example:
linux:
hosts:
davidedoro.it:
localhost:
the playbook file upgrade_linux.yml:
--
- hosts: linux
tasks:
- name: Upgrade all packages on RedHat Systems
yum:
name: '*'
state: latest
become: yes
when: ansible_os_family == "RedHat"
- name: Update Cache on Debian Systems
apt:
update_cache: yes
when: ansible_os_family == "Debian"
- name: Upgrade
apt:
name: "*"
state: latest
become: yes
when: ansible_os_family == "Debian"
to run the playbook using a non root user:
$ ansible-playbook -b -v --ask-become-pass -i hosts upgrade_linux.ym
ansible/playbooks.txt · Last modified: 2024/11/10 08:00 by 127.0.0.1
