Created
September 12, 2015 10:35
-
-
Save theory14/1ea4075287a17fb9f66e to your computer and use it in GitHub Desktop.
Ansible role for updating FreeBSD machines with freebsd-update and pkg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Check status of jailing | |
shell: "sysctl security.jail.jailed | cut -d: -f2 | tr -d ' '" | |
register: is_jail | |
when: "ansible_os_family == 'FreeBSD' " | |
- name: Fetch and Install Updates | |
command: "{{ item }}" | |
when: "ansible_os_family == 'FreeBSD' and is_jail.stdout == '0'" | |
ignore_errors: yes | |
with_items: | |
- "freebsd-update --not-running-from-cron fetch" | |
- "freebsd-update --not-running-from-cron install" | |
- name: pkg updates | |
command: " {{ item }} " | |
when: "ansible_os_family == 'FreeBSD'" | |
with_items: | |
- "pkg update -q" | |
- "pkg upgrade -y" | |
- "pkg clean -qy" | |
- name: Check for jails | |
shell: "jls | grep -v JID | wc -l | tr -d ' '" | |
register: has_jails | |
when: "ansible_os_family == 'FreeBSD'" | |
- name: Update base jail | |
command: 'ezjail-admin update -u' | |
when: "ansible_os_family == 'FreeBSD' and has_jails.stdout != '0' and is_jail.stdout == '0'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is more clever than | cut | tr