Expanded Ansible notions

This commit is contained in:
Michele Cereda
2023-02-04 21:41:04 +01:00
parent 2b53bad9c9
commit 5dfe346fa0
4 changed files with 1064 additions and 3 deletions

View File

@@ -15,6 +15,7 @@
"duperemove",
"fdupes",
"flatpak",
"getfacl",
"gpgtools",
"growpart",
"hadolint",
@@ -33,6 +34,7 @@
"nvme",
"ocsp",
"pacman",
"pamac",
"pkexec",
"polkit",
"pvresize",
@@ -41,6 +43,8 @@
"rootlv",
"rootvg",
"runcmd",
"setfacl",
"sshpass",
"subvolume",
"tclsh",
"templating",

View File

@@ -0,0 +1,32 @@
---
- name: Upgrade a Darwin system
hosts: all
gather_facts: false
vars:
homebrew_installed: false
macports_installed: false
mas_installed: false
tasks:
- name: Install system ugrades
ansible.builtin.command: softwareupdate --install --recommended
register: softwareupdate_result
changed_when:
- softwareupdate_result.stderr != 'No updates are available.'
- name: Update homebrew and upgrade all packages
when: homebrew_installed
community.general.homebrew:
update_homebrew: true
upgrade_all: true
- name: Update Macports and the ports tree, then upgrade all outdated ports
when: macports_installed
become: true
community.general.macports:
selfupdate: true
upgrade: true
register: macports_result
changed_when: macports_result.stdout is not regex('Nothing to upgrade.')
- name: Upgrade all installed Mac App Store apps
when: mas_installed
community.general.mas:
upgrade_all: true

File diff suppressed because it is too large Load Diff

View File

@@ -32,9 +32,13 @@
pip3 install --user 'ansible' && port install 'sshpass' # darwin
sudo pamac install 'ansible' 'sshpass' # manjaro linux
# Generate an example configuration file with all entries disabled.
ansible-config init --disabled > 'ansible.cfg'
ansible-config init --disabled -t 'all' > 'ansible.cfg'
# Show hosts' ansible facts.
ansible -i 'path/to/hosts/file' -m 'setup' all
ansible -i 'host1,hostn,' -m 'setup' 'host1' -u 'remote-user'
ansible -i 'host1,hostN,' -m 'setup' 'host1' -u 'remote-user'
ansible -i 'localhost,' -c 'local' -km 'setup' 'localhost'
# Check the syntax of a playbook.
@@ -43,7 +47,7 @@ ansible-playbook 'path/to/playbook.yml' --syntax-check
# Execute a playbook.
ansible-playbook 'path/to/playbook.yml' -i 'hosts.list'
ansible-playbook … -i 'host1,host2,hostn,' -l 'hosts,list'
ansible-playbook … -i 'host1,host2,hostN,' -l 'hosts,list'
ansible-playbook … -i 'host1,host2,other,' -l 'hosts-pattern'
# Show what changes (with details) a play would apply to the local machine.
@@ -84,7 +88,7 @@ Ansible will process the following list and use the first file found; all the ot
1. the `ANSIBLE_CONFIG` environment variable;
1. the `ansible.cfg` file in the current directory;
1. the `~/.ansible.cfg` file in the home directory;
1. the `~/.ansible.cfg` file in the user's home directory;
1. the `/etc/ansible/ansible.cfg` file.
One can generate a fully commented-out example of the `ansible.cfg` file: