From 3470709ecdd28e7def205f121bf92cb3e537736d Mon Sep 17 00:00:00 2001 From: jeet Date: Wed, 27 Dec 2023 13:24:44 -0500 Subject: [PATCH] check if its installed --- playbooks/config-nextdns.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/playbooks/config-nextdns.yml b/playbooks/config-nextdns.yml index 4138b83..52001e0 100644 --- a/playbooks/config-nextdns.yml +++ b/playbooks/config-nextdns.yml @@ -3,18 +3,14 @@ gather_facts: yes tasks: - - name: Download and install NextDNS CLI - ansible.builtin.expect: - command: sh -c 'sh -c "$(curl -sL https://nextdns.io/install)"' - responses: - Question: - - 'Choice (default=i):' : 'i' - - 'NextDNS Profile ID (default=e3448e):' : 'e3448e' - - 'Report device name? [Y|n]:' : 'Y' - - 'Enable caching? [Y|n]:' : 'Y' - - 'Enable instant refresh? (y/n):' : 'Y' + - name: Check if NextDNS is installed + ansible.builtin.shell: apt list --installed | grep nextdns + register: nextdns_status + ignore_errors: True + check_mode: False + changed_when: False - - name: Start NextDNS CLI - ansible.builtin.command: - cmd: nextdns start - ignore_errors: yes \ No newline at end of file + - name: Download and Install NextDNS CLI + ansible.builtin.shell: + cmd: printf "i\ne3448e\nY\nY\nY" |sh -c 'sh -c "$(curl -sL https://nextdns.io/install)"' + when: nextdns_status.rc == 0 \ No newline at end of file