Major refactor of Packer Vagrant+Docker logic 91/36791/4
authorDaniel Farrell <dfarrell@redhat.com>
Mon, 28 Mar 2016 22:07:30 +0000 (18:07 -0400)
committerDaniel Farrell <dfarrell@redhat.com>
Mon, 4 Apr 2016 14:46:39 +0000 (10:46 -0400)
* Reorganize files/dirs to scale to larger number of builds
* Extract vars from templates more completely
* Support building ODL 3.4, 4.0 and 4.1
* Still using the latest CentOS ISO, 7.2.1511
* Built versions: atlas.hashicorp.com/opendaylight/boxes/odl

Change-Id: Ib23777663913ed8c727a5d5383fb0707c0c95daa
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
14 files changed:
packer/centos.json [deleted file]
packer/packer_vars.json [deleted file]
packer/provision/centos_kickstart.cfg [moved from packer/centos_kickstart.cfg with 100% similarity]
packer/provision/config_ansible.sh [moved from packer/config_ansible.sh with 95% similarity]
packer/provision/config_docker.sh [moved from packer/config_docker.sh with 100% similarity]
packer/provision/config_vagrant.sh [moved from packer/config_vagrant.sh with 100% similarity]
packer/provision/config_virtualbox.sh [moved from packer/config_virtualbox.sh with 100% similarity]
packer/provision/install_odl.yml [moved from packer/install_odl.yml with 100% similarity]
packer/templates/docker.json [new file with mode: 0644]
packer/templates/libvirt.json [new file with mode: 0644]
packer/templates/virtualbox.json [new file with mode: 0644]
packer/vars/opendaylight-3.4.0-centos-7.2.1511.json [new file with mode: 0644]
packer/vars/opendaylight-4.0.0-centos-7.2.1511.json [new file with mode: 0644]
packer/vars/opendaylight-4.1.0-centos-7.2.1511.json [new file with mode: 0644]

diff --git a/packer/centos.json b/packer/centos.json
deleted file mode 100644 (file)
index bfdac91..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-{
-  "variables": {
-    "box_version": null,
-    "docker_version": null,
-    "docker_name": null
-  },
-  "builders": [
-    {
-      "type": "qemu",
-      "iso_urls":
-        [
-          "http://mirrors.rit.edu/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso",
-          "http://mirrors.usc.edu/pub/linux/distributions/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso",
-          "http://centos.eecs.wsu.edu/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso",
-          "http://mirror.lug.udel.edu/pub/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso",
-          "http://mirror.cc.columbia.edu/pub/linux/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso"
-        ],
-      "iso_checksum": "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284",
-      "iso_checksum_type": "sha256",
-      "ssh_username": "vagrant",
-      "ssh_password": "vagrant",
-      "ssh_wait_timeout": "20m",
-      "shutdown_command": "sudo shutdown -P now",
-      "http_directory": ".",
-      "boot_command":
-        [
-        "<tab>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos_kickstart.cfg<enter>"
-        ]
-    },
-    {
-      "type": "virtualbox-iso",
-      "guest_os_type": "RedHat_64",
-      "iso_urls":
-        [
-          "http://mirrors.seas.harvard.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1503-01.iso",
-          "http://bay.uchicago.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1503-01.iso",
-          "http://mirror.vcu.edu/pub/gnu+linux/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1503-01.iso",
-          "http://mirror.vtti.vt.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1503-01.iso",
-          "http://mirror.clarkson.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1503-01.iso"
-        ],
-      "iso_checksum": "7cf1ac8da13f54d6be41e3ccf228dc5bb35792f515642755ff4780d5714d4278",
-      "iso_checksum_type": "sha256",
-      "headless": "false",
-      "ssh_username": "vagrant",
-      "ssh_password": "vagrant",
-      "ssh_wait_timeout": "20m",
-      "shutdown_command": "sudo shutdown -P now",
-      "http_directory": ".",
-      "boot_command": [
-        "<tab>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/centos_kickstart.cfg<enter>"
-      ],
-      "vboxmanage": [
-        [
-          "modifyvm",
-          "{{ .Name }}",
-          "--memory",
-          "1024"
-        ],
-        [
-          "modifyvm",
-          "{{ .Name }}",
-          "--cpus",
-          "2"
-        ]
-      ]
-    },
-    {
-      "type": "docker",
-      "image": "centos:7.1.1503",
-      "pull": false,
-      "commit": true
-    }
-  ],
-  "provisioners": [
-    {
-      "type": "shell",
-      "scripts":
-        [
-          "config_vagrant.sh",
-          "config_ansible.sh"
-        ],
-      "only":
-        [
-          "qemu"
-        ]
-    },
-    {
-      "type": "shell",
-      "scripts":
-        [
-          "config_virtualbox.sh",
-          "config_vagrant.sh",
-          "config_ansible.sh"
-        ],
-      "only":
-        [
-          "virtualbox-iso"
-        ]
-    },
-    {
-      "type": "shell",
-      "scripts":
-        [
-          "config_docker.sh",
-          "config_ansible.sh"
-        ],
-      "only":
-        [
-          "docker"
-        ]
-    },
-    {
-      "type": "ansible-local",
-      "playbook_file": "install_odl.yml"
-    }
-  ],
-  "post-processors": [
-    {
-      "type": "vagrant",
-      "compression_level": "9",
-      "output": "opendaylight-{{ user `box_version` }}-centos-7.2.1511-libvirt.box",
-      "only": ["qemu"]
-    },
-    {
-      "type": "vagrant",
-      "compression_level": "9",
-      "output": "opendaylight-{{ user `box_version` }}-centos-1503-virtualbox.box",
-      "only": ["virtualbox-iso"]
-    },
-    {
-      "type": "docker-tag",
-      "repository": "{{ user `docker_name` }}",
-      "tag": "{{ user `docker_version` }}",
-      "force": true,
-      "only": ["docker"]
-    }
-  ]
-}
diff --git a/packer/packer_vars.json b/packer/packer_vars.json
deleted file mode 100644 (file)
index bd8a8d6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-  "box_version": "4.0.0",
-  "docker_version": "4.0.0",
-  "docker_name": "opendaylight/odl"
-}
similarity index 95%
rename from packer/config_ansible.sh
rename to packer/provision/config_ansible.sh
index a8d5f3578c137f669e8809c8f84e0784436ef1ba..20796323851e9aff45eae34bd8982cd0520b8169 100644 (file)
@@ -10,9 +10,8 @@ set -x
 sudo yum install -y epel-release
 
 # Install Ansible, required for Packer's ansible-local provisioner
-# Recent versions of Ansible require ansible-playbook
 # Git is required by the ansible-galaxy tool when installing roles
-sudo yum install -y ansible ansible-playbook git
+sudo yum install -y ansible git
 
 # Install the latest release of ODL's Ansible role from Ansible Galaxy
 # The `ansible-galaxy` tool was installed by Ansible's RPM
diff --git a/packer/templates/docker.json b/packer/templates/docker.json
new file mode 100644 (file)
index 0000000..4bf6a1d
--- /dev/null
@@ -0,0 +1,44 @@
+{
+  "variables": {
+    "odl_version": null,
+    "centos_version": null,
+    "docker_repo": null,
+    "rpm_repo_file": null,
+    "rpm_repo_url": null
+  },
+  "builders": [
+    {
+      "type": "docker",
+      "image": "centos:{{ user `centos_version` }}",
+      "pull": false,
+      "commit": true
+    }
+  ],
+  "provisioners": [
+    {
+      "type": "shell",
+      "scripts":
+        [
+          "provision/config_docker.sh",
+          "provision/config_ansible.sh"
+        ]
+    },
+    {
+      "type": "ansible-local",
+      "playbook_file": "provision/install_odl.yml",
+      "extra_arguments": [
+        "--extra-vars",
+        "\"rpm_repo_file={{ user `rpm_repo_file` }}",
+        "rpm_repo_url={{ user `rpm_repo_url` }}\""
+      ]
+    }
+  ],
+  "post-processors": [
+    {
+      "type": "docker-tag",
+      "repository": "{{ user `docker_repo` }}",
+      "tag": "{{ user `odl_version` }}",
+      "force": true,
+    }
+  ]
+}
diff --git a/packer/templates/libvirt.json b/packer/templates/libvirt.json
new file mode 100644 (file)
index 0000000..e4a38e3
--- /dev/null
@@ -0,0 +1,53 @@
+{
+  "variables": {
+    "odl_version": null,
+    "centos_version": null,
+    "iso_urls": null,
+    "iso_checksum": null,
+    "rpm_repo_file": null,
+    "rpm_repo_url": null
+  },
+  "builders": [
+    {
+      "type": "qemu",
+      "iso_urls": "{{ user `iso_urls` }}",
+      "iso_checksum": "{{ user `iso_checksum` }}",
+      "iso_checksum_type": "sha256",
+      "ssh_username": "vagrant",
+      "ssh_password": "vagrant",
+      "ssh_wait_timeout": "20m",
+      "shutdown_command": "sudo shutdown -P now",
+      "http_directory": ".",
+      "boot_command":
+        [
+        "<tab>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/provision/centos_kickstart.cfg<enter>"
+        ]
+    }
+  ],
+  "provisioners": [
+    {
+      "type": "shell",
+      "scripts":
+        [
+          "provision/config_vagrant.sh",
+          "provision/config_ansible.sh"
+        ]
+    },
+    {
+      "type": "ansible-local",
+      "playbook_file": "provision/install_odl.yml",
+      "extra_arguments": [
+        "--extra-vars",
+        "\"rpm_repo_file={{ user `rpm_repo_file` }}",
+        "rpm_repo_url={{ user `rpm_repo_url` }}\""
+      ]
+    }
+  ],
+  "post-processors": [
+    {
+      "type": "vagrant",
+      "compression_level": "9",
+      "output": "opendaylight-{{ user `odl_version` }}-centos-{{ user `centos_version` }}-libvirt.box"
+    }
+  ]
+}
diff --git a/packer/templates/virtualbox.json b/packer/templates/virtualbox.json
new file mode 100644 (file)
index 0000000..2d6f684
--- /dev/null
@@ -0,0 +1,68 @@
+{
+  "variables": {
+    "odl_version": null,
+    "centos_version": null,
+    "docker_repo": null,
+    "rpm_repo_file": null,
+    "rpm_repo_url": null
+  },
+  "builders": [
+    {
+      "type": "virtualbox-iso",
+      "guest_os_type": "RedHat_64",
+      "iso_urls": "{{ user `iso_urls` }}",
+      "iso_checksum": "{{ user `iso_checksum` }}",
+      "iso_checksum_type": "sha256",
+      "headless": "false",
+      "ssh_username": "vagrant",
+      "ssh_password": "vagrant",
+      "ssh_wait_timeout": "20m",
+      "shutdown_command": "sudo shutdown -P now",
+      "http_directory": ".",
+      "boot_command": [
+        "<tab>text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/provision/centos_kickstart.cfg<enter>"
+      ],
+      "vboxmanage": [
+        [
+          "modifyvm",
+          "{{ .Name }}",
+          "--memory",
+          "1024"
+        ],
+        [
+          "modifyvm",
+          "{{ .Name }}",
+          "--cpus",
+          "2"
+        ]
+      ]
+    }
+  ],
+  "provisioners": [
+    {
+      "type": "shell",
+      "scripts":
+        [
+          "provision/config_virtualbox.sh",
+          "provision/config_vagrant.sh",
+          "provision/config_ansible.sh"
+        ]
+    },
+    {
+      "type": "ansible-local",
+      "playbook_file": "provision/install_odl.yml",
+      "extra_arguments": [
+        "--extra-vars",
+        "\"rpm_repo_file={{ user `rpm_repo_file` }}",
+        "rpm_repo_url={{ user `rpm_repo_url` }}\""
+      ]
+    }
+  ],
+  "post-processors": [
+    {
+      "type": "vagrant",
+      "compression_level": "9",
+      "output": "opendaylight-{{ user `odl_version` }}-centos-{{ user `centos_version` }}-virtualbox.box"
+    }
+  ]
+}
diff --git a/packer/vars/opendaylight-3.4.0-centos-7.2.1511.json b/packer/vars/opendaylight-3.4.0-centos-7.2.1511.json
new file mode 100644 (file)
index 0000000..64235ae
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "odl_version": "3.4.0",
+  "centos_version": "7.2.1511",
+  "iso_urls": "http://mirrors.rit.edu/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso",
+  "iso_checksum": "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284",
+  "docker_repo": "opendaylight/odl",
+  "rpm_repo_file": "opendaylight-34-release.repo",
+  "rpm_repo_url": "'https://git.opendaylight.org/gerrit/gitweb?p=integration/packaging.git;a=blob_plain;f=rpm/example_repo_configs/opendaylight-34-release.repo'"
+}
diff --git a/packer/vars/opendaylight-4.0.0-centos-7.2.1511.json b/packer/vars/opendaylight-4.0.0-centos-7.2.1511.json
new file mode 100644 (file)
index 0000000..fb0fbfc
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "odl_version": "4.0.0",
+  "centos_version": "7.2.1511",
+  "iso_urls": "http://mirrors.rit.edu/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso",
+  "iso_checksum": "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284",
+  "docker_repo": "opendaylight/odl",
+  "rpm_repo_file": "opendaylight-40-release.repo",
+  "rpm_repo_url": "'https://git.opendaylight.org/gerrit/gitweb?p=integration/packaging.git;a=blob_plain;f=rpm/example_repo_configs/opendaylight-40-release.repo'"
+}
diff --git a/packer/vars/opendaylight-4.1.0-centos-7.2.1511.json b/packer/vars/opendaylight-4.1.0-centos-7.2.1511.json
new file mode 100644 (file)
index 0000000..a99761c
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "odl_version": "4.1.0",
+  "centos_version": "7.2.1511",
+  "iso_urls": "http://mirrors.rit.edu/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso",
+  "iso_checksum": "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284",
+  "docker_repo": "opendaylight/odl",
+  "rpm_repo_file": "opendaylight-41-release.repo",
+  "rpm_repo_url": "'https://git.opendaylight.org/gerrit/gitweb?p=integration/packaging.git;a=blob_plain;f=rpm/example_repo_configs/opendaylight-41-release.repo'"
+}