Repository :
http://git.fedorahosted.org/cgit/copr.git
On branch : master
---------------------------------------------------------------
commit ffc3a80f2e3e83f836ab506a6121d9e6f3816b42
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Sep 12 14:30:00 2013 +0200
put examples of builderpb.yml and terminatepb.yml into doc dir
---------------------------------------------------------------
copr-be.conf.example | 1 +
copr-setup.txt | 1 +
copr.spec | 2 +
playbooks/builderpb.yml | 75 +++++++++++++++++++++++++++++++++++++++++++++
playbooks/terminatepb.yml | 16 +++++++++
5 files changed, 95 insertions(+), 0 deletions(-)
diff --git a/copr-be.conf.example b/copr-be.conf.example
index bde41cd..d19953e 100644
--- a/copr-be.conf.example
+++ b/copr-be.conf.example
@@ -10,6 +10,7 @@
frontend_url=http://copr-fe.cloud.fedoraproject.org/backend
frontend_auth=backend_password_from_fe_config
# path to ansible playbook which spawns builder
+# see /usr/share/copr*/playbooks/ for examples
spawn_playbook=/srv/copr-work/provision/builderpb.yml
# path to ansible playbook which terminate builder
diff --git a/copr-setup.txt b/copr-setup.txt
index 4f955a6..e6a6381 100644
--- a/copr-setup.txt
+++ b/copr-setup.txt
@@ -20,6 +20,7 @@ ansible playbook:
- frontend_auth must have same value as BACKEND_PASSWORD from have frontend in
/etc/copr/copr.conf
- spawn_playbook - path to ansible playbook which spawns builder
- terminate_playbook - path to ansible playbook which terminate builder
+ - you can see /usr/share/copr*/playbooks/ for examples
- others variables can be edited as well, but it is optional
Required pkgs:
diff --git a/copr.spec b/copr.spec
index 96cb8fa..c5e4e89 100644
--- a/copr.spec
+++ b/copr.spec
@@ -156,6 +156,7 @@ install -m 644 man/copr-cli.1 %{buildroot}/%{_mandir}/man1/
#doc
cp -a documentation/python-doc %{buildroot}%{_pkgdocdir}/
+cp -a playbooks %{buildroot}%{_pkgdocdir}/
%pre backend
getent group copr >/dev/null || groupadd -r copr
@@ -182,6 +183,7 @@ service httpd condrestart
%ghost %{_var}/log/copr/copr.log
%ghost %{_var}/log/copr/workers/worker-*.log
%doc %{_pkgdocdir}/lighttpd
+%doc %{_pkgdocdir}/playbooks
%config(noreplace) %{_sysconfdir}/copr/copr-be.conf
%{_datadir}/copr/backend
diff --git a/playbooks/builderpb.yml b/playbooks/builderpb.yml
new file mode 100644
index 0000000..be486f4
--- /dev/null
+++ b/playbooks/builderpb.yml
@@ -0,0 +1,75 @@
+---
+- name: check/create instance
+ hosts: localhost
+ user: copr
+ gather_facts: False
+
+ vars:
+ - keypair: buildsys
+ - image: ami-0000000e
+ - instance_type: m1.builder
+ - security_group: builder
+
+ tasks:
+ - name: spin it up
+ local_action: ec2 keypair=${keypair} image=${image} type=${instance_type} wait=true
group=${security_group}
+ register: inst_res
+
+ - name: get its internal ip b/c openstack is sometimes stupid
+ local_action: shell euca-describe-instances ${inst_res.instances[0].id} | grep
INSTANCE | cut -f 18
+ register: int_ip
+
+ - name: add it to the special group
+ local_action: add_host hostname=${int_ip.stdout} groupname=builder_temp_group
+
+ - name: wait for the host to be hot
+ local_action: wait_for host=${int_ip.stdout} port=22 delay=5 timeout=600
+
+
+- hosts: builder_temp_group
+ user: root
+ vars:
+ - files: files/
+
+ tasks:
+ - name: edit hostname to be instance name
+ action: shell hostname `curl -s
http://169.254.169.254/2009-04-04/meta-data/instance-id`
+
+ - name: add repos
+ action: copy src=$files/$item dest=/etc/yum.repos.d/$item
+ with_items:
+ - builder.repo
+ - epel6.repo
+
+ - name: install pkgs
+ action: yum state=present pkg=$item
+ with_items:
+ - mock
+ - createrepo
+ - yum-utils
+ - rsync
+ - openssh-clients
+
+ - name: make sure newest rpm
+ action: yum name=rpm state=latest
+
+ - name: mockbuilder user
+ action: user name=mockbuilder groups=mock
+
+ - name: mockbuilder .ssh
+ action: file state=directory path=/home/mockbuilder/.ssh mode=0700 owner=mockbuilder
group=mockbuilder
+
+ - name: mockbuilder authorized_keys
+ action: authorized_key user=mockbuilder key='$FILE(${files}/buildsys.pub)'
+
+ - name: put updated mock configs into /etc/mock
+ action: copy src=$files/mock/$item dest=/etc/mock
+ with_items:
+ - site-defaults.cfg
+ - epel-5-x86_64.cfg
+ - epel-5-i386.cfg
+
+ - name: put updated mockchain into /usr/bin
+ action: copy src=$files/mockchain dest=/usr/bin/mockchain mode=0755 owner=root
group=root
+
+
diff --git a/playbooks/terminatepb.yml b/playbooks/terminatepb.yml
new file mode 100644
index 0000000..a95f810
--- /dev/null
+++ b/playbooks/terminatepb.yml
@@ -0,0 +1,16 @@
+---
+- name: terminate instance
+ hosts: all
+ user: root
+ gather_facts: False
+
+ tasks:
+ - name: find the instance id from the builder
+ action: command curl -s
http://169.254.169.254/latest/meta-data/instance-id
+ register: instanceid
+
+ - name: terminate it
+ local_action: command euca-terminate-instances ${instanceid.stdout}
+
+
+