summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
Diffstat (limited to 'roles')
-rw-r--r--roles/epgtrim/tasks/main.yml8
-rw-r--r--roles/flatbot/files/config2
-rw-r--r--roles/flatbot/files/flatbot.service13
-rw-r--r--roles/flatbot/files/flatbot.timer8
-rw-r--r--roles/flatbot/files/token9
-rw-r--r--roles/flatbot/files/urls5
-rw-r--r--roles/flatbot/handlers/main.yml3
-rw-r--r--roles/flatbot/meta/main.yml2
-rw-r--r--roles/flatbot/tasks/main.yml54
-rw-r--r--roles/pacman/handlers/main.yml3
-rw-r--r--roles/pacman/tasks/main.yml8
11 files changed, 111 insertions, 4 deletions
diff --git a/roles/epgtrim/tasks/main.yml b/roles/epgtrim/tasks/main.yml
index 7a521e9..ee3db04 100644
--- a/roles/epgtrim/tasks/main.yml
+++ b/roles/epgtrim/tasks/main.yml
@@ -14,14 +14,14 @@
- name: Configure epgtrim service
ansible.builtin.copy:
- src: files/{{ item }}
- dest: /usr/lib/systemd/system/{{ item }}
+ src: '{{ item }}'
+ dest: /usr/lib/systemd/system
owner: root
group: root
mode: u+rw,g+r,o+r
loop:
- - epgtrim.service
- - epgtrim.timer
+ - files/epgtrim.service
+ - files/epgtrim.timer
- name: Enable epgtrim systemd timer
ansible.builtin.service:
diff --git a/roles/flatbot/files/config b/roles/flatbot/files/config
new file mode 100644
index 0000000..80983bb
--- /dev/null
+++ b/roles/flatbot/files/config
@@ -0,0 +1,2 @@
+FLATBOT_TELEGRAM_CHAT_ID=-1001856540467
+FLATBOT_STATE=/var/lib/flatbot/state.json
diff --git a/roles/flatbot/files/flatbot.service b/roles/flatbot/files/flatbot.service
new file mode 100644
index 0000000..7a66500
--- /dev/null
+++ b/roles/flatbot/files/flatbot.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Run flatbot once
+After=network.target
+
+[Service]
+Type=oneshot
+EnvironmentFile=/etc/flatbot/token
+EnvironmentFile=/etc/flatbot/config
+EnvironmentFile=/etc/flatbot/urls
+ExecStart=/usr/bin/flatbot -state ${FLATBOT_STATE} -once ${GREENWICH} ${CLERKENWELL} ${HAMPSTEAD} ${EAST_FINCHLEY} ${HIGHGATE}
+
+[Install]
+WantedBy=default.target
diff --git a/roles/flatbot/files/flatbot.timer b/roles/flatbot/files/flatbot.timer
new file mode 100644
index 0000000..86b3c6c
--- /dev/null
+++ b/roles/flatbot/files/flatbot.timer
@@ -0,0 +1,8 @@
+[Unit]
+Description=Run flatbot everyday
+
+[Timer]
+OnCalendar=*-*-* 19:00:00
+
+[Install]
+WantedBy=timers.target
diff --git a/roles/flatbot/files/token b/roles/flatbot/files/token
new file mode 100644
index 0000000..bbffbad
--- /dev/null
+++ b/roles/flatbot/files/token
@@ -0,0 +1,9 @@
+$ANSIBLE_VAULT;1.1;AES256
+34333332343831383539383634633538333933623561366234623232663530363230623937633537
+3037303934613733643161343866313835383961396336380a323337396339333638316264623666
+30363161613834373638333835636433353637653235333535613632653163663936623833613362
+3635633862363365350a336337663432623630393335363563623266656264633033326435386561
+31303631623834333830393665343966326330616439636136643337366239343466663166653061
+38306331613532616464393563333530653335393061303831623134366162643465616635363130
+61303462326234636137663265373035666462313066616534306538623738326635666333626431
+35646363346632316533
diff --git a/roles/flatbot/files/urls b/roles/flatbot/files/urls
new file mode 100644
index 0000000..05738a7
--- /dev/null
+++ b/roles/flatbot/files/urls
@@ -0,0 +1,5 @@
+GREENWICH=https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&propertyTypes=detached,semi-detached,terraced&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&tenureTypes=FREEHOLD,SHARE_OF_FREEHOLD&maxPrice=900000&radius=0.5&locationIdentifier=STATION^6122&maxDaysSinceAdded=7
+CLERKENWELL=https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&maxPrice=900000&radius=0.5&locationIdentifier=STATION^3431&maxDaysSinceAdded=7
+HAMPSTEAD=https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&maxPrice=900000&locationIdentifier=REGION^87509&transactionType=BUY&maxDaysSinceAdded=7
+EAST_FINCHLEY=https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&maxPrice=900000&locationIdentifier=REGION^70375&transactionType=BUY&maxDaysSinceAdded=7
+HIGHGATE=https://www.rightmove.co.uk/property-for-sale/find.html?minBedrooms=2&sortType=2&areaSizeUnit=sqft&channel=BUY&index=0&maxPrice=900000&locationIdentifier=REGION^70315&transactionType=BUY&maxDaysSinceAdded=7
diff --git a/roles/flatbot/handlers/main.yml b/roles/flatbot/handlers/main.yml
new file mode 100644
index 0000000..38cca3c
--- /dev/null
+++ b/roles/flatbot/handlers/main.yml
@@ -0,0 +1,3 @@
+- name: Reload units
+ ansible.builtin.systemd_service:
+ daemon_reload: true
diff --git a/roles/flatbot/meta/main.yml b/roles/flatbot/meta/main.yml
new file mode 100644
index 0000000..99c8bbf
--- /dev/null
+++ b/roles/flatbot/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - role: pacman
diff --git a/roles/flatbot/tasks/main.yml b/roles/flatbot/tasks/main.yml
new file mode 100644
index 0000000..4a4509c
--- /dev/null
+++ b/roles/flatbot/tasks/main.yml
@@ -0,0 +1,54 @@
+- name: Install flatbot
+ ansible.builtin.package:
+ name:
+ - flatbot
+ state: present
+
+- name: Create flatbot directories
+ ansible.builtin.file:
+ path: '{{ item }}'
+ state: directory
+ owner: root
+ group: root
+ mode: u+rwx,g+rx,o+rx
+ loop:
+ - /etc/flatbot
+ - /var/lib/flatbot
+
+- name: Configure flatbot
+ ansible.builtin.copy:
+ src: '{{ item }}'
+ dest: /etc/flatbot
+ owner: root
+ group: root
+ mode: u+rw,g+r,o+r
+ loop:
+ - files/config
+ - files/urls
+
+- name: Copy flatbot token config
+ ansible.builtin.copy:
+ src: files/token
+ dest: /etc/flatbot
+ owner: root
+ group: root
+ mode: u+rw,g-r,o-r
+
+- name: Configure flatbot service
+ ansible.builtin.copy:
+ src: '{{ item }}'
+ dest: /usr/lib/systemd/system
+ owner: root
+ group: root
+ mode: u+rw,g+r,o+r
+ notify:
+ - Reload units
+ loop:
+ - files/flatbot.service
+ - files/flatbot.timer
+
+- name: Enable flatbot systemd timer
+ ansible.builtin.service:
+ name: flatbot.timer
+ enabled: true
+ state: started
diff --git a/roles/pacman/handlers/main.yml b/roles/pacman/handlers/main.yml
new file mode 100644
index 0000000..575536d
--- /dev/null
+++ b/roles/pacman/handlers/main.yml
@@ -0,0 +1,3 @@
+- name: Update packages db
+ community.general.pacman:
+ update_cache: true
diff --git a/roles/pacman/tasks/main.yml b/roles/pacman/tasks/main.yml
index e7c9a9a..87f4cab 100644
--- a/roles/pacman/tasks/main.yml
+++ b/roles/pacman/tasks/main.yml
@@ -15,8 +15,16 @@
owner: root
group: root
mode: u+rw,g+r,o+r
+ notify:
+ - Update packages db
loop:
- regexp: '^[misc]'
line: '[misc]'
- regexp: '^Include = /etc/pacman.d/misc'
line: 'Include = /etc/pacman.d/misc'
+
+# Usually, handlers run after all tasks are completed, but it doesn't work for
+# this case, because we are going to install package from misc repository, so
+# we need to have package db up to date.
+- name: Force packages db update
+ ansible.builtin.meta: flush_handlers