- name: install xen gather_facts: no hosts: "{{target}}" become: "{{become}}" vars: baseline_pkgs: - libnl3 # required by xen-nox - lzo # required by xen-nox tasks: - name: required baseline packages ansible.builtin.shell: executable: /bin/bash cmd: | set -e for pkgname in {{ baseline_pkgs | join(' ') }}; do echo -n $pkgname ... if [[ {{ansible_check_mode}} = True ]]; then ls /var/log/packages/$pkgname-* >/dev/null 2>&1 && echo there || echo WILL INSTALL IN PLAY elif [[ {{ansible_check_mode}} = False ]]; then ls /var/log/packages/$pkgname-* >/dev/null 2>&1 && echo there || slackpkg -dialog=off -batch=on -default_answer=y install $pkgname fi done; unset pkgname register: baseline changed_when: > 'WILL INSTALL IN PLAY' in baseline.stdout or 'Installing package' in baseline.stdout check_mode: false - debug: var=baseline.stdout when: baseline.stdout != '' - debug: var=baseline.stderr when: baseline.stderr != '' # todo - grab the packages - name: required sbo packages ansible.builtin.shell: executable: /bin/bash cmd: | set -e cd slackpkgs-gonzales3/ for f in *.tgz; do pkgname=${f%%-*} echo -n $pkgname ... if [[ {{ansible_check_mode}} = True ]]; then ls /var/log/packages/$pkgname-* >/dev/null 2>&1 && echo there || echo WILL INSTALL IN PLAY elif [[ {{ansible_check_mode}} = False ]]; then ls /var/log/packages/$pkgname-* >/dev/null 2>&1 && echo there || installpkg --terse *.tgz fi cd ../ done; unset f register: sbo changed_when: > 'WILL INSTALL IN PLAY' in baseline.stdout or 'Installing package' in baseline.stdout check_mode: false - debug: var=sbo.stdout when: sbo.stdout != '' - debug: var=sbo.stderr when: sbo.stderr != '' - name: enable xencommons lineinfile: path: /etc/rc.d/rc.local line: /etc/rc.d/init.d/xencommons start diff: true