--- - hosts: localhost gather_facts: no tasks: - shell: "[ ! -f wg.pub ] && wg genkey | tee wg.priv | wg pubkey | tee wg.pub || true" register: output changed_when: output.stdout != ""