[PATCH] Refactor the code deploying zodbot/ursabot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Michael Scherer <misc@xxxxxxxx>

Since there is the same code between staging and production, except
for the bot name, using a variable permit to avoid duplication.
---
 roles/supybot/tasks/main.yml | 36 ++++++++----------------------------
 roles/supybot/vars/main.yml  |  3 +++
 2 files changed, 11 insertions(+), 28 deletions(-)
 create mode 100644 roles/supybot/vars/main.yml

diff --git a/roles/supybot/tasks/main.yml b/roles/supybot/tasks/main.yml
index 59cc5ea..36bfce9 100644
--- a/roles/supybot/tasks/main.yml
+++ b/roles/supybot/tasks/main.yml
@@ -10,34 +10,23 @@
   - packagedb-cli
   tags: supybot
 
+- set_fact: botname=botnames[env]
+
 - name: creating zodbot log dir
   file: path={{ item }} state=directory owner=daemon
   with_items:
-  - /var/lib/zodbot
-  - /var/lib/zodbot/conf
-  - /var/lib/zodbot/data
-  - /var/lib/zodbot/logs
+  - /var/lib/{{ botname }}
+  - /var/lib/{{ botname }}/conf
+  - /var/lib/{{ botname }}/data
+  - /var/lib/{{ botname }}/logs
   - /srv/web
   - /srv/web/meetbot
-  when: env != "staging"
   tags: supybot
 
 - name: create teams directory
   file: path=/srv/web/meetbot/teams state=directory owner=apache group=apache mode=0755
   tags: supybot
 
-- name: creating usrabot log dir
-  file: path={{ item }} state=directory owner=daemon
-  with_items:
-  - /var/lib/ursabot
-  - /var/lib/ursabot/conf
-  - /var/lib/ursabot/data
-  - /var/lib/ursabot/logs
-  - /srv/web
-  - /srv/web/meetbot
-  when: env == "staging"
-  tags: supybot
-
 - name: setup meetings_by_team script
   copy: src=meetings_by_team.sh dest=/usr/local/bin/meetings_by_team.sh mode=755
   tags: supybot
@@ -70,18 +59,9 @@
   - meetbot
   - supybot
 
-- name: setup cron job to start zodbot/ursabot on boot
-  cron: name=zodbot special_time=reboot job='cd /srv/web/meetbot; supybot -d /var/lib/zodbot/conf/zodbot.conf' user=daemon
-  tags:
-  - config
-  - meetbot
-  - supybot
-  when: env != "staging"
-
-- name: setup cron job to start zodbot/ursabot on boot
-  cron: name=ursabot special_time=reboot job='cd /srv/web/meetbot; supybot -d /var/lib/ursabot/conf/ursabot.conf' user=daemon
+- name: setup cron job to start {{ botname }}/ursabot on boot
+  cron: name={{ botname }} special_time=reboot job='cd /srv/web/meetbot; supybot -d /var/lib/{{ botname }}/conf/{{ botname }}.conf' user=daemon
   tags:
   - config
   - meetbot
   - supybot
-  when: env == "staging"
diff --git a/roles/supybot/vars/main.yml b/roles/supybot/vars/main.yml
new file mode 100644
index 0000000..6e3df99
--- /dev/null
+++ b/roles/supybot/vars/main.yml
@@ -0,0 +1,3 @@
+botnames:
+  staging: ursabot
+  production: zodbot
-- 
1.8.3.1
_______________________________________________
infrastructure mailing list
infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
http://lists.fedoraproject.org/admin/lists/infrastructure@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux