diff mbox series

[ovs-dev] poc: Automate building of Fedora rpm packages

Message ID 20180424030042.6288-1-aatteka@ovn.org
State Superseded
Headers show
Series [ovs-dev] poc: Automate building of Fedora rpm packages | expand

Commit Message

Ansis Atteka April 24, 2018, 3 a.m. UTC
This patch automates building of Fedora rpm packages (Just
like we are already doing this for for CentOS and Ubuntu).

Signed-off-by: Ansis Atteka <aatteka@ovn.org>
---
 poc/builders/Vagrantfile        |  12 +++++
 poc/playbook-fedora-builder.yml | 117 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+)
 create mode 100644 poc/playbook-fedora-builder.yml

Comments

Aaron Conole April 24, 2018, 8:10 p.m. UTC | #1
Ansis Atteka <aatteka@ovn.org> writes:

> This patch automates building of Fedora rpm packages (Just
> like we are already doing this for for CentOS and Ubuntu).
>
> Signed-off-by: Ansis Atteka <aatteka@ovn.org>
> ---

Maybe it's something wrong with my setup - but for the fedorabuilder
image I get a stall "Waiting for domain to get an IP address..." and it
doesn't proceed.  On the other hand, the centos and ubuntu still proceed
as normal.

Are you also able to observe this?  I probably did something wrong, but
all I did was:

  $ git am ~/News/poc.patch
  $ vagrant up fedorabuilder
  ...
  ==> fedorabuilder: Starting domain.
  ==> fedorabuilder: Waiting for domain to get an IP address...
  ==> fedorabuilder: Removing domain...
  ==> fedorabuilder: An error occurred. The error will be shown after all tasks complete.
  An error occurred while executing multiple actions in parallel.
  Any errors that occurred are shown below.
  
  An unexpected error occurred when executing the action on the
  'fedorabuilder' machine. Please report this as a bug:
  
  The specified wait_for timeout (2 seconds) was exceeded
  
  /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:9:in `block in wait_for'
  /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:6:in `loop'
  /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:6:in `wait_for'
  /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/model.rb:69:in `wait_for'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:42:in `block (2 levels) in call'
  /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/util/retryable.rb:17:in `retryable'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:37:in `block in call'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/util/timer.rb:9:in `time'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:34:in `call'
  /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/start_domain.rb:298:in `call'
  /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/set_boot_order.rb:78:in `call'
  /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/create_network_interfaces.rb:176:in `call'
  /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/create_networks.rb:83:in `call'
  /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/share_folders.rb:20:in `call'
  /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
  /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/prepare_nfs_settings.rb:18:in `call'
  /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
  ...

-Aaron
Ansis April 24, 2018, 8:59 p.m. UTC | #2
On 24 April 2018 at 13:10, Aaron Conole <aconole@redhat.com> wrote:
> Ansis Atteka <aatteka@ovn.org> writes:
>
>> This patch automates building of Fedora rpm packages (Just
>> like we are already doing this for for CentOS and Ubuntu).
>>
>> Signed-off-by: Ansis Atteka <aatteka@ovn.org>
>> ---
>
> Maybe it's something wrong with my setup - but for the fedorabuilder
> image I get a stall "Waiting for domain to get an IP address..." and it
> doesn't proceed.  On the other hand, the centos and ubuntu still proceed
> as normal.

Thanks for trying this out!

>
> Are you also able to observe this?  I probably did something wrong, but
> all I did was:
>
>   $ git am ~/News/poc.patch
>   $ vagrant up fedorabuilder

That is exactly the same command I ran. Though, I believe your default
provider is libvirt and not virtualbox?



>   ...
>   ==> fedorabuilder: Starting domain.
>   ==> fedorabuilder: Waiting for domain to get an IP address...

I reproduced the exact same error with --provider=libvirt argument.
Thanks for catching this. I suspect that generic/fedora27 works on
virtualbox, but does not work on libvirt. Will try to find fedora27
box that works with both providers.

>   ==> fedorabuilder: Removing domain...
>   ==> fedorabuilder: An error occurred. The error will be shown after all tasks complete.
>   An error occurred while executing multiple actions in parallel.
>   Any errors that occurred are shown below.
>
>   An unexpected error occurred when executing the action on the
>   'fedorabuilder' machine. Please report this as a bug:
>
>   The specified wait_for timeout (2 seconds) was exceeded
>
>   /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:9:in `block in wait_for'
>   /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:6:in `loop'
>   /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:6:in `wait_for'
>   /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/model.rb:69:in `wait_for'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:42:in `block (2 levels) in call'
>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/util/retryable.rb:17:in `retryable'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:37:in `block in call'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/util/timer.rb:9:in `time'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:34:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/start_domain.rb:298:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/set_boot_order.rb:78:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/create_network_interfaces.rb:176:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/create_networks.rb:83:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/share_folders.rb:20:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/prepare_nfs_settings.rb:18:in `call'
>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in `call'
>   ...
>
> -Aaron
Aaron Conole April 24, 2018, 9:11 p.m. UTC | #3
Ansis Atteka <ansisatteka@gmail.com> writes:

> On 24 April 2018 at 13:10, Aaron Conole <aconole@redhat.com> wrote:
>> Ansis Atteka <aatteka@ovn.org> writes:
>>
>>> This patch automates building of Fedora rpm packages (Just
>>> like we are already doing this for for CentOS and Ubuntu).
>>>
>>> Signed-off-by: Ansis Atteka <aatteka@ovn.org>
>>> ---
>>
>> Maybe it's something wrong with my setup - but for the fedorabuilder
>> image I get a stall "Waiting for domain to get an IP address..." and it
>> doesn't proceed.  On the other hand, the centos and ubuntu still proceed
>> as normal.
>
> Thanks for trying this out!
>
>>
>> Are you also able to observe this?  I probably did something wrong, but
>> all I did was:
>>
>>   $ git am ~/News/poc.patch
>>   $ vagrant up fedorabuilder
>
> That is exactly the same command I ran. Though, I believe your default
> provider is libvirt and not virtualbox?

Yes, that is true.

>
>
>>   ...
>>   ==> fedorabuilder: Starting domain.
>>   ==> fedorabuilder: Waiting for domain to get an IP address...
>
> I reproduced the exact same error with --provider=libvirt argument.
> Thanks for catching this. I suspect that generic/fedora27 works on
> virtualbox, but does not work on libvirt. Will try to find fedora27
> box that works with both providers.

Strange.  I look forward to seeing it work :)

>>   ==> fedorabuilder: Removing domain...
>>   ==> fedorabuilder: An error occurred. The error will be shown
>> after all tasks complete.
>>   An error occurred while executing multiple actions in parallel.
>>   Any errors that occurred are shown below.
>>
>>   An unexpected error occurred when executing the action on the
>>   'fedorabuilder' machine. Please report this as a bug:
>>
>>   The specified wait_for timeout (2 seconds) was exceeded
>>
>>   /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:9:in
>> `block in wait_for'
>>   /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:6:in `loop'
>>   /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/wait_for.rb:6:in `wait_for'
>>   /usr/share/gems/gems/fog-core-1.43.0/lib/fog/core/model.rb:69:in `wait_for'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:42:in
>> `block (2 levels) in call'
>>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/util/retryable.rb:17:in
>> `retryable'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:37:in
>> `block in call'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/util/timer.rb:9:in
>> `time'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/wait_till_up.rb:34:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/start_domain.rb:298:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/set_boot_order.rb:78:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/create_network_interfaces.rb:176:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/create_networks.rb:83:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/share_folders.rb:20:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-libvirt-0.0.40/lib/vagrant-libvirt/action/prepare_nfs_settings.rb:18:in
>> `call'
>>   /usr/share/vagrant/gems/gems/vagrant-2.0.2/lib/vagrant/action/warden.rb:34:in
>> `call'
>>   ...
>>
>> -Aaron
diff mbox series

Patch

diff --git a/poc/builders/Vagrantfile b/poc/builders/Vagrantfile
index af2986789..9f5fa5dce 100644
--- a/poc/builders/Vagrantfile
+++ b/poc/builders/Vagrantfile
@@ -30,4 +30,16 @@  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
     end
   end
 
+  # Fedora  builder host
+  config.vm.define "fedorabuilder" do |builder|
+    builder.vm.hostname = "fedoraubuilder.dev"
+    builder.vm.box = "generic/fedora27"
+    builder.vm.synced_folder "../../", "/git/ovs", type: "rsync",
+                             rsync__args: ["--archive", "--delete", "-z"]
+    builder.vm.provision "builder", type: "ansible" do |ansible|
+      ansible.playbook = "../playbook-fedora-builder.yml"
+      ansible.sudo = true
+    end
+  end
+
 end
diff --git a/poc/playbook-fedora-builder.yml b/poc/playbook-fedora-builder.yml
new file mode 100644
index 000000000..5d7efb3a6
--- /dev/null
+++ b/poc/playbook-fedora-builder.yml
@@ -0,0 +1,117 @@ 
+---
+- hosts: all
+  become: true
+  name: builder
+  tasks:
+
+  - name: Create Ansible Local Facts Directory
+    file: path=/etc/ansible/facts.d state=directory
+
+  - name: Install "yum-utils", "rpmdevtools", "createrepo", "httpd", "git"
+    dnf: name={{item}} state=present
+    with_items:
+      - yum-utils
+      - rpmdevtools
+      - createrepo
+      - httpd
+      - git
+      - libselinux-python
+
+  - name: Initiate Build Numbering
+    copy:
+        content: '{ "release":"1" }'
+        dest: "/etc/ansible/facts.d/builder.fact"
+        force: no
+
+  - name: Set source directory for building
+    set_fact:
+        SOURCE: "/root/rpmbuild/SOURCES"
+
+  - name: Reload Ansible Local Facts
+    setup: filter=ansible_local
+
+  - name: Remove untracked files from Open vSwitch GIT repository
+    command: chdir=/git/ovs/ git clean -xdf
+
+  - name: Reset Open vSwitch GIT repository to last comitted state
+    command: chdir=/git/ovs/ git reset --hard
+
+  - name: Generate spec files for easy build dependency retrieval
+    shell: sed -e 's/@VERSION@/0.0.1/' {{item}}.in > /tmp/{{item}}
+    args:
+        chdir: /git/ovs/rhel
+    with_items:
+      - openvswitch-fedora.spec
+      - openvswitch-kmod-fedora.spec
+      - openvswitch-dkms.spec
+
+  - name: Install build dependencies specified from spec files
+    shell: echo "y" | yum-builddep /tmp/{{item}}
+    with_items:
+      - openvswitch-fedora.spec
+      - openvswitch-kmod-fedora.spec
+      - openvswitch-dkms.spec
+
+  - name: Create rpm dev tree
+    command: rpmdev-setuptree
+
+  - name: Run "./boot.sh"
+    command: chdir=/git/ovs/ ./boot.sh
+
+  - name: Run "./configure"
+    command: chdir=/git/ovs/ ./configure
+
+  - name: Run "make dist"
+    command: chdir=/git/ovs/ make dist
+
+  - name: Parse out Open vSwitch version from "configure.ac"
+    command: chdir=/git/ovs autoconf -t AC_INIT:'$2'
+    register: version
+
+  - name: Copy source tarball to rpm dev tree
+    command: cp /git/ovs/openvswitch-{{version.stdout}}.tar.gz {{SOURCE}}
+
+  - name: Unarchive openvswitch source tarball
+    unarchive:
+       src: "{{SOURCE}}/openvswitch-{{version.stdout}}.tar.gz"
+       dest: "{{SOURCE}}"
+       remote_src: yes
+
+  - name: Update release number in spec files
+    lineinfile:
+      path: "{{SOURCE}}/openvswitch-{{version.stdout}}/rhel/{{item}}"
+      regexp: '^Release:'
+      line: "Release: {{ ansible_local.builder.release }}"
+    with_items:
+      - openvswitch-fedora.spec
+      - openvswitch-kmod-fedora.spec
+      - openvswitch-dkms.spec
+
+  - name: Build Open vSwitch user space rpms
+    command: rpmbuild -bb --without check rhel/openvswitch-fedora.spec
+    args:
+        chdir: "{{SOURCE}}/openvswitch-{{version.stdout}}"
+
+  - name: Build Open vSwitch kmod rpm
+    command: rpmbuild -bb --without check rhel/openvswitch-fedora.spec
+    args:
+        chdir: "{{SOURCE}}/openvswitch-{{version.stdout}}"
+
+  - name: Build Open vSwitch dkms rpm
+    command: rpmbuild -bb --without check rhel/openvswitch-dkms.spec
+    args:
+        chdir: "{{SOURCE}}/openvswitch-{{version.stdout}}"
+
+  - name: Copy RPM packages to /var/www/html
+    command: cp -r /root/rpmbuild/RPMS/ /var/www/html
+
+  - name: Create RPM Package index file for repository
+    command: chdir=/var/www/html createrepo /var/www/html
+
+  - name: Make sure Apache is running
+    systemd: state=started name=httpd
+
+  - name: Bump up Build Number
+    copy:
+        content: '{ "release":"{{ansible_local.builder.release|int+1}}" }'
+        dest: "/etc/ansible/facts.d/builder.fact"