diff --git a/tasks/main.yml b/tasks/main.yml index ab966ae..a5e54f4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -42,12 +42,9 @@ # with_items: "{{ hass_user }}" - name: check repo - - git: - repo: "{{hass_repo}}" - dest: "{{hass_conf_folder}}" - clone: no - update: no + become: yes + stat: + path: "{{hass_conf_folder}}/.git" # required. The full path of the file/object to get the facts of. register: hass_repo_exist - name: clean conf folder if repo not exist @@ -55,14 +52,15 @@ file: path: "{{hass_conf_folder}}" state: absent - + when: hass_repo_exist.stat.exists == false + - name: recreate conf folder become: yes file: path: "{{hass_conf_folder}}" state: directory owner: "{{user.name}}" - + when: hass_repo_exist.stat.exists == false - name: install conf file git: @@ -71,6 +69,7 @@ clone: yes # not required. If C(no), do not clone the repository if it does not exist locally version: "{{hass_repo_branch}}" notify: restart hass + when: hass_repo_exist.stat.exists == false - name: change owner become: yes @@ -89,11 +88,12 @@ notify: restart fail2ban become: yes -- name: create cron for dyndns +- name: create cron for hass cron: - job: "sh {{{{hass_conf_folder}}/backup_git.sh" + job: "sh {{hass_conf_folder}}/backup_git.sh" user: root # not required. The specific user whose crontab should be modified. - minute: 00 03 * * * # not required. Minute when the job should run ( 0-59, *, */2, etc ) + minute: "0" # not required. Minute when the job should run ( 0-59, *, */2, etc ) + hour: "3" name: "auto commit HASS config" # not required. Description of a crontab entry or, if env is set, the name of environment variable. Required if state=absent. Note that if name is not set and state=present, then a new crontab entry will always be created, regardless of existing ones. become: yes diff --git a/templates/fail2ban/hass.local.j2 b/templates/fail2ban/hass.local.j2 index 907e498..00e3876 100644 --- a/templates/fail2ban/hass.local.j2 +++ b/templates/fail2ban/hass.local.j2 @@ -6,4 +6,4 @@ filter = hass logpath = {{hass_conf_folder}}/home-assistant.log findtime = 3600 # Maximum amount of login attempts before IP is blocked -maxretry = 3 \ No newline at end of file +maxretry = 5 \ No newline at end of file