#199 Add a cron based deployment for badge on the frontend
Merged 3 years ago by misc. Opened 3 years ago by misc.
fedora-infra/ misc/ansible add_cron_badges  into  master

@@ -0,0 +1,6 @@ 

+ #!/bin/bash

+ set -e

+ 

+ cd /srv/badges_checkout/

+ git pull

+ ( rsync --delete -ar --itemize-changes /srv/badges_checkout/rules/ /srv/web/infra/badges/rules/ | grep -q '^>f' ) && service fedmsg-hub restart

@@ -57,19 +57,38 @@ 

    - badges

    - badges/backend

  

- - name: copy over all our badge definitions

+ - name: create checkout dir

+   file:

+     name: /srv/badges_checkout

+     state: directory

+   tags:

+   - badges

+   - badges/backend

+ 

+ - name: clone directory

+   git:

+     repo:

+     dest: /srv/badges_checkout

+   tags:

+   - badges

+   - badges/backend

+ 

+ - name: add script

    copy:

-     src: /srv/web/infra/badges/rules/

-     dest: /usr/share/badges/rules/

-     owner: fedmsg

-     group: fedmsg

-     mode: 0644

+     dest: /usr/local/bin/update_checkout.sh

+     src: update_checkout.sh

+     mode: 0755

+   tags:

+   - badges

+   - badges/backend

+ 

+ - name: add cron for update

+   cron:

+     job: /usr/local/bin/update_checkout.sh

+     minute: "*/15"

    tags:

-   - config

    - badges

    - badges/backend

-   notify:

-   - restart fedmsg-hub

  

  - name: ensure the fedmsg user has a homedir for cron to work

    file:

@@ -0,0 +1,8 @@ 

+ #!/bin/bash

+ set -e

+ 

+ cd /srv/badges_checkout/

+ git pull

+ for i in pngs stls ; do

+     rsync --delete -ar /srv/badges_checkout/$i /srv/web/infra/badges/$i/

+ done

@@ -102,21 +102,38 @@ 

    - badges

    - badges/frontend

  

- - name: copy over all our badge images

-   synchronize:

-     src: /srv/web/infra/badges/pngs/

-     dest: /usr/share/badges/pngs/

-     delete: yes

+ - name: create checkout dir

+   file:

+     name: /srv/badges_checkout

+     state: directory

    tags:

-   - assets

+   - badges

+   - badges/frontend

  

- - name: copy over all our badge stls

-   synchronize:

-     src: /srv/web/infra/badges/stls/

-     dest: /usr/share/badges/stls/

-     delete: yes

+ - name: clone directory

+   git:

+     repo:

+     dest: /srv/badges_checkout

    tags:

-   - assets

+   - badges

+   - badges/frontend

+ 

+ - name: add script

+   copy:

+     dest: /usr/local/bin/update_checkout.sh

+     src: update_checkout.sh

+     mode: 0755

+   tags:

+   - badges

+   - badges/frontend

+ 

+ - name: add cron for update

+   cron:

+     job: /usr/local/bin/update_checkout.sh

+     minute: "*/15"

+   tags:

+   - badges

+   - badges/frontend

  

  - name: ensure selinux lets httpd talk to postgres, memcached, and fedmsg

    seboolean:

no initial comment

rebased onto a6b16f5d3f035a143ca62fbeeefa3ff9f9880c83

3 years ago

I'd recommend to move this as a var since you're using in couple of places and as a result install your script as a template

rebased onto b8eb0520db8e1d2e42107e2f26d58722f5f2390e

3 years ago

are there any chances happening into that folder that require a --rebase?

1 new commit added

  • Add a cron to copy rules and restart
3 years ago

Looks fine to me. +1 to merge/push out whenever (badges isn't frozen)

rebased onto 2c2d9633afb19dfd4a10278a5b3340cdd9945126

3 years ago

rebased onto 5e40a04

3 years ago

rebased onto 5e40a04

3 years ago

Pull-Request has been merged by misc

3 years ago

Seems this trigger a bug in ansible:

fatal: [badges-backend01.iad2.fedoraproject.org]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\n    fname, loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\n    mod_name, mod_fname, mod_loader, pkg_name)\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\n    exec code in run_globals\n  File \"/tmp/ansible_git_payload_xsfZXG/ansible_git_payload.zip/ansible/modules/source_control/git.py\", line 1269, in <module>\n  File \"/tmp/ansible_git_payload_xsfZXG/ansible_git_payload.zip/ansible/modules/source_control/git.py\", line 1110, in main\n  File \"/usr/lib64/python2.7/posixpath.py\", line 261, in expanduser\n    if not path.startswith('~'):\nAttributeError: 'NoneType' object has no attribute 'startswith'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

I guess because I forgot to add the repo....