Обновить playbooks/update_exclusions.yml

This commit is contained in:
2026-08-27 00:07:27 +03:00
parent 7ab079dd6f
commit 9b99d658c4
+12 -10
View File
@@ -4,9 +4,8 @@
gather_facts: no gather_facts: no
vars: vars:
exclusions_url: "https://raw.githubusercontent.com/lib4u/amnezia-tunneling-ru/main/amnezia.json" exclusions_url: "https://raw.githubusercontent.com/lib4u/amnezia-tunneling-ru/main/amnezia.json"
# альтернативный список: https://raw.githubusercontent.com/Internet-Helper/Unblock-for-Russia/main/for-AGH.txt telegram_token: "8820292312:AAECFO1AEWOJTh30zNuhyjC5C81o_qJHQcM"
telegram_token: "{{ telegram_token }}" # задать в AWX как extra_var или credential telegram_chat_id: "407968638"
telegram_chat_id: "{{ telegram_chat_id }}"
tasks: tasks:
- name: Download current exclusion list - name: Download current exclusion list
ansible.builtin.uri: ansible.builtin.uri:
@@ -14,13 +13,13 @@
return_content: yes return_content: yes
register: exclusions_raw register: exclusions_raw
- name: Extract domains from JSON (if JSON) - name: Extract domains from JSON (amnezia.json format)
ansible.builtin.set_fact: ansible.builtin.set_fact:
domains: "{{ exclusions_raw.content | from_json | json_query('domains') }}" domains: "{{ exclusions_raw.content | from_json | json_query('domains') }}"
when: exclusions_raw.content | from_json | type_debug == 'dict' when: exclusions_raw.content | from_json | type_debug == 'dict'
ignore_errors: yes ignore_errors: yes
- name: Extract domains from plain text (if not JSON) - name: Extract domains from plain text (fallback)
ansible.builtin.set_fact: ansible.builtin.set_fact:
domains: "{{ exclusions_raw.content | split('\n') | reject('match', '^#') | reject('match', '^$') | list }}" domains: "{{ exclusions_raw.content | split('\n') | reject('match', '^#') | reject('match', '^$') | list }}"
when: domains is not defined when: domains is not defined
@@ -45,7 +44,7 @@
loop: "{{ domains }}" loop: "{{ domains }}"
when: domains | length > 0 when: domains | length > 0
loop_control: loop_control:
pause: 0.1 # небольшая задержка, чтобы не перегрузить CLI pause: 0.1
changed_when: true changed_when: true
- name: Restart VPN to apply changes - name: Restart VPN to apply changes
@@ -53,11 +52,14 @@
cmd: "adguardvpn-cli disconnect && adguardvpn-cli connect" cmd: "adguardvpn-cli disconnect && adguardvpn-cli connect"
changed_when: true changed_when: true
- name: Send Telegram notification - name: Send Telegram notification via API
community.general.telegram: ansible.builtin.uri:
token: "{{ telegram_token }}" url: "https://api.telegram.org/bot{{ telegram_token }}/sendMessage"
api_args: method: POST
body_format: json
body:
chat_id: "{{ telegram_chat_id }}" chat_id: "{{ telegram_chat_id }}"
text: "✅ Список исключений обновлён. Добавлено {{ domains | length }} доменов." text: "✅ Список исключений обновлён. Добавлено {{ domains | length }} доменов."
disable_web_page_preview: yes
delegate_to: localhost delegate_to: localhost
when: telegram_token is defined and telegram_chat_id is defined when: telegram_token is defined and telegram_chat_id is defined