From e1cc854acf14c11f054c98111ecdf3471b4d556f Mon Sep 17 00:00:00 2001 From: Tim Flink Date: Mon, 25 Jan 2016 21:50:46 +0000 Subject: [PATCH] remove a bunch of taskotron-specific stuff from buildmaster into taskotron master, add tmpwatch cronjob --- playbooks/groups/taskotron.yml | 1 + roles/taskotron/buildmaster/tasks/main.yml | 24 ++----------------- roles/taskotron/master/defaults/main.yml | 3 +++ roles/taskotron/master/tasks/main.yml | 20 ++++++++++++++++ .../templates/artifacts.conf.j2 | 0 .../templates/taskotron-tmpwatch.cron.j2 | 2 ++ 6 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 roles/taskotron/master/defaults/main.yml create mode 100644 roles/taskotron/master/tasks/main.yml rename roles/taskotron/{buildmaster => master}/templates/artifacts.conf.j2 (100%) create mode 100644 roles/taskotron/master/templates/taskotron-tmpwatch.cron.j2 diff --git a/playbooks/groups/taskotron.yml b/playbooks/groups/taskotron.yml index f9e5294a17..5dc9f7979a 100644 --- a/playbooks/groups/taskotron.yml +++ b/playbooks/groups/taskotron.yml @@ -52,6 +52,7 @@ - { role: taskotron/buildmaster-configure, tags: ['buildmasterconfig'] } - { role: taskotron/taskotron-trigger, tags: ['trigger'] } - { role: taskotron/taskotron-frontend, tags: ['frontend'] } + - { role: taskotron/taskotron-master, tags: ['taskotronmaster'] } handlers: - include: "{{ handlers }}/restart_services.yml" diff --git a/roles/taskotron/buildmaster/tasks/main.yml b/roles/taskotron/buildmaster/tasks/main.yml index 9f76865847..f082947c46 100644 --- a/roles/taskotron/buildmaster/tasks/main.yml +++ b/roles/taskotron/buildmaster/tasks/main.yml @@ -45,19 +45,6 @@ notify: - reload httpd -- name: copy artifacts httpd config - template: src=artifacts.conf.j2 dest=/etc/httpd/conf.d/artifacts.conf owner=root group=root - when: deployment_type == 'prod' or deployment_type == 'stg' or deployment_type == 'dev' or deployment_type == 'local' - notify: - - reload httpd - -- name: create artifacts directory - file: path={{ item }} state=directory owner=buildmaster group=buildmaster mode=0775 setype=httpd_sys_content_t - when: deployment_type == 'prod' or deployment_type == 'stg' or deployment_type == 'dev' or deployment_type == 'local' - with_items: - - /srv/taskotron - - /srv/taskotron/artifacts - - name: ensure buildmaster database is created when: buildmaster_db_host != 'localhost' delegate_to: "{{ buildmaster_db_host }}" @@ -66,18 +53,11 @@ postgresql_db: db={{ buildmaster_db_name }} - name: ensure dev db user has access to dev database - when: deployment_type == 'dev' + when: deployment_type in ['dev', 'stg'] delegate_to: "{{ buildmaster_db_host }}" sudo: true sudo_user: postgres - postgresql_user: db={{ buildmaster_db_name }} user={{ dev_buildmaster_db_user }} password={{ dev_buildmaster_db_password }} role_attr_flags=NOSUPERUSER - -- name: ensure stg db user has access to stg database - when: deployment_type == 'stg' - delegate_to: "{{ buildmaster_db_host }}" - sudo: true - sudo_user: postgres - postgresql_user: db={{ buildmaster_db_name }} user={{ stg_buildmaster_db_user }} password={{ stg_buildmaster_db_password }} role_attr_flags=NOSUPERUSER + postgresql_user: db={{ buildmaster_db_name }} user={{ buildmaster_db_user }} password={{ buildmaster_db_password }} role_attr_flags=NOSUPERUSER - name: ensure prod db user has access to prod database when: deployment_type == 'prod' diff --git a/roles/taskotron/master/defaults/main.yml b/roles/taskotron/master/defaults/main.yml new file mode 100644 index 0000000000..9951dd3f77 --- /dev/null +++ b/roles/taskotron/master/defaults/main.yml @@ -0,0 +1,3 @@ +--- +artifacts_max_life: '120d' +buildmaster_max_life: '150d' diff --git a/roles/taskotron/master/tasks/main.yml b/roles/taskotron/master/tasks/main.yml new file mode 100644 index 0000000000..97f28fc208 --- /dev/null +++ b/roles/taskotron/master/tasks/main.yml @@ -0,0 +1,20 @@ +--- +- name: ensure packages required for buildmaster are installed (dnf) + dnf: name={{ item }} state=present enablerepo={{ extra_enablerepos }} + with_items: + - tmpwatch + when: ansible_distribution_major_version|int > 21 and ansible_cmdline.ostree is not defined + +- name: create artifacts directory + file: path={{ item }} state=directory owner=buildmaster group=buildmaster mode=0775 setype=httpd_sys_content_t + with_items: + - /srv/taskotron + - /srv/taskotron/artifacts + +- name: copy artifacts httpd config + template: src=artifacts.conf.j2 dest=/etc/httpd/conf.d/artifacts.conf owner=root group=root + notify: + - reload httpd + +- name: copy tmpwatch cronjob for taskotron artifacts and buildmaster + template: src=taskotron-tmpwatch.cron.jw dest=/etc/cron.d/taskotron-tmpwatch.cron owner=root group=root mode=0644 diff --git a/roles/taskotron/buildmaster/templates/artifacts.conf.j2 b/roles/taskotron/master/templates/artifacts.conf.j2 similarity index 100% rename from roles/taskotron/buildmaster/templates/artifacts.conf.j2 rename to roles/taskotron/master/templates/artifacts.conf.j2 diff --git a/roles/taskotron/master/templates/taskotron-tmpwatch.cron.j2 b/roles/taskotron/master/templates/taskotron-tmpwatch.cron.j2 new file mode 100644 index 0000000000..175c354f58 --- /dev/null +++ b/roles/taskotron/master/templates/taskotron-tmpwatch.cron.j2 @@ -0,0 +1,2 @@ +0 0 * * * {{ buildmaster_user }} tmpwatch -vv --dirmtime -m -f {{ artifacts_max_life }} {{ public_artifacts_dir }} +0 0 * * * {{ buildmaster_user }} tmpwatch -vv --dirmtime -m -f {{ buildmaster_max_life }} {{ public_artifacts_dir }}