From 77d48a533dc194436935aaf0d673bef40983b919 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 02:08:12 +0300 Subject: Add Ansible playbook to setup buildbot instance more easily --- testing/README.md | 5 +++++ testing/buildbot.yml | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 testing/README.md create mode 100644 testing/buildbot.yml diff --git a/testing/README.md b/testing/README.md new file mode 100644 index 0000000..9da8ff8 --- /dev/null +++ b/testing/README.md @@ -0,0 +1,5 @@ +Here lie various files related to SCons that +can not find the place in other directories: + + buildbot.yml - Ansible playbook to set up + buildbot for running tests diff --git a/testing/buildbot.yml b/testing/buildbot.yml new file mode 100644 index 0000000..8590215 --- /dev/null +++ b/testing/buildbot.yml @@ -0,0 +1,20 @@ +# Ansible playbook to setup buildbot instance +# http://scons.org/wiki/InstallingBuildbotSlaves +--- +# host is overridable with --extra-vars 'host=address' +- hosts: "{{ host | default('localhost') }}" + vars: + - botuser: scons2 + - hgrc: /home/{{ botuser }}/.hgrc + + tasks: + # --- install requirements --- + - name: ubuntu/debian - make sure mercurial is installed + apt: pkg=mercurial + + - name: create .hgrc if necessary + command: touch {{ hgrc }} creates={{ hgrc }} + - name: enable mercurial purge extension + ini_file: dest={{ hgrc }} backup=yes + section=extensions option=hgext.purge + value= -- cgit v0.12 From d2b747cb8a4338e9d14bcaf9d3778737e5741d1a Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 05:27:35 +0300 Subject: buildbot.yml: Set .hgrc owner as botuser --- testing/buildbot.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index 8590215..9ae341a 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -1,5 +1,10 @@ # Ansible playbook to setup buildbot instance # http://scons.org/wiki/InstallingBuildbotSlaves +# +# Send questions to: +# +# anatoly techtonik +# --- # host is overridable with --extra-vars 'host=address' - hosts: "{{ host | default('localhost') }}" @@ -13,7 +18,7 @@ apt: pkg=mercurial - name: create .hgrc if necessary - command: touch {{ hgrc }} creates={{ hgrc }} + file: path={{ hgrc }} owner={{ botuser }} state=touch - name: enable mercurial purge extension ini_file: dest={{ hgrc }} backup=yes section=extensions option=hgext.purge -- cgit v0.12 From c9b8c43646d06d8a0fb3b20d0416cdde615e7109 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 06:21:03 +0300 Subject: buildbot.yml: Touch .hgrc only if necessary --- testing/buildbot.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index 9ae341a..b912bc8 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -18,7 +18,10 @@ apt: pkg=mercurial - name: create .hgrc if necessary - file: path={{ hgrc }} owner={{ botuser }} state=touch + stat: path={{ hgrc }} + register: st + - file: path={{ hgrc }} owner={{ botuser }} state=touch + when: not st.stat.exists - name: enable mercurial purge extension ini_file: dest={{ hgrc }} backup=yes section=extensions option=hgext.purge -- cgit v0.12 From da4468b8f5dbb4e3a3f09c1d757636f6576356ea Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 06:35:44 +0300 Subject: buildbot.yml: python-virtualenv is needed --- testing/buildbot.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index b912bc8..d64182a 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -15,7 +15,10 @@ tasks: # --- install requirements --- - name: ubuntu/debian - make sure mercurial is installed - apt: pkg=mercurial + apt: pkg={{ item }} + with_items: + - mercurial + - python-virtualenv - name: create .hgrc if necessary stat: path={{ hgrc }} -- cgit v0.12 From 7d77766255048a05a2f67a0eaa2dfc354ac9e64b Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 07:11:30 +0300 Subject: buildbot.yml: Change bot user to 'scons' and explain how to override --- testing/buildbot.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index d64182a..0bf2856 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -9,7 +9,8 @@ # host is overridable with --extra-vars 'host=address' - hosts: "{{ host | default('localhost') }}" vars: - - botuser: scons2 + # botuser can be overridden with -e 'botuser=scons2' + - botuser: scons - hgrc: /home/{{ botuser }}/.hgrc tasks: -- cgit v0.12 From 12753c7775b659aca390b6bc48cf2cb117b8a2c0 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 07:12:12 +0300 Subject: buildbot.yml: Create virtualenv --- testing/buildbot.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index 0bf2856..38986e8 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -12,6 +12,7 @@ # botuser can be overridden with -e 'botuser=scons2' - botuser: scons - hgrc: /home/{{ botuser }}/.hgrc + - venv: /home/{{ botuser }}/buildbot-virtualenv tasks: # --- install requirements --- @@ -21,6 +22,7 @@ - mercurial - python-virtualenv + # --- enable mercurial purge extension --- - name: create .hgrc if necessary stat: path={{ hgrc }} register: st @@ -30,3 +32,8 @@ ini_file: dest={{ hgrc }} backup=yes section=extensions option=hgext.purge value= + + # --- setup virtualenv for buildbot --- + - name: setup buildbot-virtualenv + command: /usr/bin/virtualenv {{ venv }} + creates={{ venv }}/bin -- cgit v0.12 From 01020250a853d6922066f09b48b616041824df94 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 07:15:20 +0300 Subject: buildbot: Explain how to run and add hosts file --- testing/README.md | 2 ++ testing/buildbot.hosts | 1 + testing/buildbot.yml | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 testing/buildbot.hosts diff --git a/testing/README.md b/testing/README.md index 9da8ff8..bb81ce2 100644 --- a/testing/README.md +++ b/testing/README.md @@ -3,3 +3,5 @@ can not find the place in other directories: buildbot.yml - Ansible playbook to set up buildbot for running tests + + buildbot.hosts - Ansible inventory file diff --git a/testing/buildbot.hosts b/testing/buildbot.hosts new file mode 100644 index 0000000..05614f6 --- /dev/null +++ b/testing/buildbot.hosts @@ -0,0 +1 @@ +localhost ansible_connection=local \ No newline at end of file diff --git a/testing/buildbot.yml b/testing/buildbot.yml index 38986e8..9c85e71 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -1,7 +1,9 @@ # Ansible playbook to setup buildbot instance # http://scons.org/wiki/InstallingBuildbotSlaves # -# Send questions to: +# ansible-playbook -i buildbot.hosts buildbot.yml -e 'botuser=scons' +# +# Tested with Ansible 1.5.0. Send questions to: # # anatoly techtonik # -- cgit v0.12 From 72b6c82bb4cb2efeb2dd51023c365e0f6a3037a4 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 07:19:51 +0300 Subject: buildbot: Keep virtualenv isolated from system packages --- testing/buildbot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index 9c85e71..c5bc3da 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -37,5 +37,5 @@ # --- setup virtualenv for buildbot --- - name: setup buildbot-virtualenv - command: /usr/bin/virtualenv {{ venv }} + command: /usr/bin/virtualenv --no-site-packages {{ venv }} creates={{ venv }}/bin -- cgit v0.12 From fa29d885681ed0ebdc3723525a18129fefcdc56a Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 07:30:03 +0300 Subject: buildbot: pip module is a better way to install buildbot-slave in virtualenv --- testing/buildbot.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index c5bc3da..d68cc59 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -35,7 +35,6 @@ section=extensions option=hgext.purge value= - # --- setup virtualenv for buildbot --- - - name: setup buildbot-virtualenv - command: /usr/bin/virtualenv --no-site-packages {{ venv }} - creates={{ venv }}/bin + # --- install buildbot --- + - name: install buildbot-slave in virtualenv + pip: name=buildbot-slave virtualenv={{ venv }} -- cgit v0.12 From c99a4df5e53877ef52450229f39c8454f9315b8b Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 08:14:52 +0300 Subject: buildbot: Create buildbot workdir, and do not backup bot .hgrc --- testing/buildbot.hosts | 2 +- testing/buildbot.yml | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/testing/buildbot.hosts b/testing/buildbot.hosts index 05614f6..3e0be7d 100644 --- a/testing/buildbot.hosts +++ b/testing/buildbot.hosts @@ -1 +1 @@ -localhost ansible_connection=local \ No newline at end of file +localhost ansible_connection=local builder=xxx pass=xxx \ No newline at end of file diff --git a/testing/buildbot.yml b/testing/buildbot.yml index d68cc59..ee82343 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -1,9 +1,16 @@ -# Ansible playbook to setup buildbot instance -# http://scons.org/wiki/InstallingBuildbotSlaves +# Ansible playbook to setup buildbot instance. +# Edit buildbot.hosts to set builder and pass variables. +# Then exec: +# +# ansible-playbook -i buildbot.hosts buildbot.yml # -# ansible-playbook -i buildbot.hosts buildbot.yml -e 'botuser=scons' +# botuser can be overridden from command line: # -# Tested with Ansible 1.5.0. Send questions to: +# ansible-playbook -i hosts buildbot.yml -e 'botuser=sconsy' +# +# Tested with Ansible 1.5.0, based on +# http://scons.org/wiki/InstallingBuildbotSlaves +# Send questions to: # # anatoly techtonik # @@ -15,6 +22,7 @@ - botuser: scons - hgrc: /home/{{ botuser }}/.hgrc - venv: /home/{{ botuser }}/buildbot-virtualenv + - work: /home/{{ botuser }}/buildbot-workdir tasks: # --- install requirements --- @@ -31,10 +39,14 @@ - file: path={{ hgrc }} owner={{ botuser }} state=touch when: not st.stat.exists - name: enable mercurial purge extension - ini_file: dest={{ hgrc }} backup=yes + ini_file: dest={{ hgrc }} section=extensions option=hgext.purge value= - # --- install buildbot --- - name: install buildbot-slave in virtualenv - pip: name=buildbot-slave virtualenv={{ venv }} + pip: name=buildbot-slave virtualenv={{ venv }} + + - name: create buildbot environment + command: "{{ venv }}/bin/buildslave create-slave --relocatable + {{ work }} buildbot.scons.org:9989 {{ builder }} {{ pass }} + creates={{ work }}" -- cgit v0.12 From e45d4cba687fa8fd6b4780b5dabce6c3584dc9c9 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 08:19:39 +0300 Subject: buildbot: No need to create relocatable workdir --- testing/buildbot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index ee82343..b92bdd7 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -47,6 +47,6 @@ pip: name=buildbot-slave virtualenv={{ venv }} - name: create buildbot environment - command: "{{ venv }}/bin/buildslave create-slave --relocatable + command: "{{ venv }}/bin/buildslave create-slave {{ work }} buildbot.scons.org:9989 {{ builder }} {{ pass }} creates={{ work }}" -- cgit v0.12 From 0cd1d5363c1cbc14349783393cd21940faa605c3 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 08:24:59 +0300 Subject: buildbot: Create workdir under botuser --- testing/buildbot.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index b92bdd7..3364668 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -50,3 +50,5 @@ command: "{{ venv }}/bin/buildslave create-slave {{ work }} buildbot.scons.org:9989 {{ builder }} {{ pass }} creates={{ work }}" + sudo: yes + sudo_user: "{{ botuser }}" -- cgit v0.12 From a3fcf694f19ab8e53ed4e028180bb88db993adf2 Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 08:51:19 +0300 Subject: buildbot: Set contact details of the buildbot owner --- testing/buildbot.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index 3364668..65f5d6f 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -24,6 +24,12 @@ - venv: /home/{{ botuser }}/buildbot-virtualenv - work: /home/{{ botuser }}/buildbot-workdir + vars_prompt: + - name: maintainer + prompt: contact details of the builbot owner + default: name + private: no + tasks: # --- install requirements --- - name: ubuntu/debian - make sure mercurial is installed @@ -52,3 +58,6 @@ creates={{ work }}" sudo: yes sudo_user: "{{ botuser }}" + + - name: set contact details of the buildbot owner + copy: dest="{{ work }}/info/admin" content="{{ maintainer }}" -- cgit v0.12 From 26c06d7fa3a726cc0f388e5ae3df86691f5c759c Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 09:42:05 +0300 Subject: buildbot: Update host details --- testing/buildbot.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index 65f5d6f..14ba76a 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -61,3 +61,10 @@ - name: set contact details of the buildbot owner copy: dest="{{ work }}/info/admin" content="{{ maintainer }}" + + - name: update host information + copy: dest="{{ work }}/info/host" + content="{{ansible_lsb.description}} + {{'\n'}}{{ansible_machine}} + {{'\n'}}{{ansible_memtotal_mb}}MB RAM + {{'\n'}}Python {{ansible_python_version}}" -- cgit v0.12 From 146973d7411197499b09d09a64c7874a4cb752eb Mon Sep 17 00:00:00 2001 From: anatoly techtonik Date: Wed, 5 Mar 2014 09:53:00 +0300 Subject: buildbot: (re)start automatically after setup --- testing/buildbot.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testing/buildbot.yml b/testing/buildbot.yml index 14ba76a..81c2143 100644 --- a/testing/buildbot.yml +++ b/testing/buildbot.yml @@ -61,6 +61,8 @@ - name: set contact details of the buildbot owner copy: dest="{{ work }}/info/admin" content="{{ maintainer }}" + notify: + - restart buildbot - name: update host information copy: dest="{{ work }}/info/host" @@ -68,3 +70,11 @@ {{'\n'}}{{ansible_machine}} {{'\n'}}{{ansible_memtotal_mb}}MB RAM {{'\n'}}Python {{ansible_python_version}}" + notify: + - restart buildbot + + handlers: + - name: restart buildbot + command: "{{ venv }}/bin/buildslave restart {{ work }}" + sudo: yes + sudo_user: "{{ botuser }}" -- cgit v0.12