Skip to content

Instantly share code, notes, and snippets.

@unakatsuo
Last active September 22, 2016 11:09
Show Gist options
  • Save unakatsuo/6bdab7701638afdc145b066029df9580 to your computer and use it in GitHub Desktop.
Save unakatsuo/6bdab7701638afdc145b066029df9580 to your computer and use it in GitHub Desktop.
packer-from-chef-bento-box
boxtemp/
output-*/
packer_cache/
{
"variables" : {
"memory" : "2048",
"host_switch": "{{env `HOST_SWITCH`}}"
},
"builders" : [
{
"type" : "virtualbox-ovf",
"source_path": "boxtemp/6.7/box.ovf",
"ssh_password": "vagrant",
"ssh_username": "vagrant",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/halt -h -p",
"vboxmanage": [
[
"modifyvm", "{{.Name}}", "--memory", "{{ user `memory` }}"
],
[
"modifyvm", "{{.Name}}", "--nictype1", "virtio"
],
[
"modifyvm", "{{.Name}}", "--nictype2", "virtio", "--nic2", "hostonly",
"--hostonlyadapter2", "{{user `host_switch`}}"
]
]
}
],
"provisioners" : [
{
"type": "file",
"source": "fastestmirror.conf",
"destination": "/tmp/fastestmirror.conf"
},
{
"type": "file",
"source": "ifcfg-eth1",
"destination": "/tmp/ifcfg-eth1"
},
{
"type" : "shell",
"execute_command": "chmod +x {{ .Path }}; echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"inline" : [
"cp /tmp/fastestmirror.conf /etc/yum/pluginconf.d/fastestmirror.conf",
"cp /tmp/ifcfg-eth1 /etc/sysconfig/network-scripts/",
"yum install -y java-1.8.0-openjdk acpid",
"useradd -d /var/lib/jenkins --system --create-home --user-group jenkins"
]
}
]
}
{
"variables" : {
"memory" : "2048",
"host_switch": "{{env `HOST_SWITCH`}}"
},
"builders" : [
{
"type" : "virtualbox-ovf",
"source_path": "boxtemp/7.2/box.ovf",
"ssh_password": "vagrant",
"ssh_username": "vagrant",
"shutdown_command": "echo 'vagrant' | sudo -S /sbin/halt -h -p",
"vboxmanage": [
[
"modifyvm", "{{.Name}}", "--memory", "{{ user `memory` }}"
],
[
"modifyvm", "{{.Name}}", "--nictype1", "virtio"
],
[
"modifyvm", "{{.Name}}", "--nictype2", "virtio", "--nic2", "hostonly",
"--hostonlyadapter2", "{{user `host_switch`}}"
]
]
}
],
"provisioners" : [
{
"type": "file",
"source": "var-lib-jenkins.2-7-1.tar.gz",
"destination": "/tmp/var-lib-jenkins.tar.gz"
},
{
"type": "file",
"source": "fastestmirror.conf",
"destination": "/tmp/fastestmirror.conf"
},
{
"type": "file",
"source": "sysconfig-docker",
"destination": "/tmp/sysconfig-docker"
},
{
"type": "file",
"source": "sysconfig-jenkins",
"destination": "/tmp/sysconfig-jenkins"
},
{
"type" : "shell",
"execute_command": "chmod +x {{ .Path }}; echo 'vagrant' | {{.Vars}} sudo -S -E sh -eux '{{.Path}}'",
"inline" : [
"cp /tmp/fastestmirror.conf /etc/yum/pluginconf.d/fastestmirror.conf",
"cp /tmp/sysconfig-docker /etc/sysconfig/docker",
"cp /tmp/sysconfig-jenkins /etc/sysconfig/jenkins",
"rpm -Uvh http://www6.atomicorp.com/channels/atomic/centos/7/x86_64/RPMS/atomic-release-1.0-21.el7.art.noarch.rpm",
"yum install -y java-1.8.0-openjdk git docker createrepo httpd wmi",
"rpm -Uvh http://pkg.jenkins-ci.org/redhat-stable/jenkins-2.7.4-1.1.noarch.rpm",
"systemctl enable docker",
"usermod -G dockerroot jenkins",
"cd /var/lib; tar zxf /tmp/var-lib-jenkins.tar.gz; rm -f /tmp/var-lib-jenkins.tar.gz",
"mkdir /var/lib/jenkins/build-cache; chown jenkins:jenkins /var/lib/jenkins/build-cache;",
"systemctl enable httpd",
"nmcli device connect eth1",
"nmcli connection modify eth1 ipv4.method manual ipv4.addresses 192.168.56.100/24 ipv4.never-default yes"
]
}
]
}
[main]
enabled=1
verbose=0
always_print_best_host = true
socket_timeout=3
# Relative paths are relative to the cachedir (and so works for users as well
# as root).
hostfilepath=timedhosts.txt
maxhostfileage=10
maxthreads=15
#exclude=.gov, facebook
#include_only=.nl,.de,.uk,.ie
include_only=.jp
#!/bin/bash
set -ex
#box_url="${1:?ERROR: Require to set download .box URL}"
box_url="http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box"
box_tmp="${2:-boxtemp}"
# ignore duplicating dir
mkdir $box_tmp || :
(
cd $box_tmp
if [ -f './.etag' ]; then
etag=$(cat ./.etag)
fi
curl --dump-header box.header ${etag:+-H "If-None-Match: ${etag}"} -o "t.box" "${box_url}"
cat box.header | awk 'BEGIN {FS=": "}/^ETag/{print $2}' > .etag
rm -f box.header
tar -xzf t.box
)
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=no
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
DEVICE=eth1
ONBOOT=yes
IPADDR=192.168.56.101
PREFIX=24
GATEWAY=192.168.56.1
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
# /etc/sysconfig/docker
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --group=dockerroot'
DOCKER_CERT_PATH=/etc/docker
# If you want to add your own registry to be used for docker search and docker
# pull use the ADD_REGISTRY option to list a set of registries, each prepended
# with --add-registry flag. The first registry added will be the first registry
# searched.
#ADD_REGISTRY='--add-registry registry.access.redhat.com'
# If you want to block registries from being used, uncomment the BLOCK_REGISTRY
# option and give it a set of registries, each prepended with --block-registry
# flag. For example adding docker.io will stop users from downloading images
# from docker.io
# BLOCK_REGISTRY='--block-registry'
# If you have a registry secured with https but do not have proper certs
# distributed, you can tell docker to not look for full authorization by
# adding the registry to the INSECURE_REGISTRY line and uncommenting it.
# INSECURE_REGISTRY='--insecure-registry'
# On an SELinux system, if you remove the --selinux-enabled option, you
# also need to turn on the docker_transition_unconfined boolean.
# setsebool -P docker_transition_unconfined 1
# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp
# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false
#
# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below line
#DOCKERBINARY=/usr/bin/docker-latest
## Path: Development/Jenkins
## Description: Jenkins Continuous Integration Server
## Type: string
## Default: "/var/lib/jenkins"
## ServiceRestart: jenkins
#
# Directory where Jenkins store its configuration and working
# files (checkouts, build reports, artifacts, ...).
#
JENKINS_HOME="/var/lib/jenkins"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Java executable to run Jenkins
# When left empty, we'll try to find the suitable Java.
#
JENKINS_JAVA_CMD=""
## Type: string
## Default: "jenkins"
## ServiceRestart: jenkins
#
# Unix user account that runs the Jenkins daemon
# Be careful when you change this, as you need to update
# permissions of $JENKINS_HOME and /var/log/jenkins.
#
JENKINS_USER="jenkins"
## Type: string
## Default: "false"
## ServiceRestart: jenkins
#
# Whether to skip potentially long-running chown at the
# $JENKINS_HOME location. Do not enable this, "true", unless
# you know what you're doing. See JENKINS-23273.
#
#JENKINS_INSTALL_SKIP_CHOWN="false"
## Type: string
## Default: "-Djava.awt.headless=true"
## ServiceRestart: jenkins
#
# Options to pass to java when running Jenkins.
#
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Djava.io.tmpdir=$JENKINS_HOME/tmp"
## Type: integer(0:65535)
## Default: 8080
## ServiceRestart: jenkins
#
# Port Jenkins is listening on.
# Set to -1 to disable
#
JENKINS_PORT="8080"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# IP address Jenkins listens on for HTTP requests.
# Default is all interfaces (0.0.0.0).
#
JENKINS_LISTEN_ADDRESS=""
## Type: integer(0:65535)
## Default: ""
## ServiceRestart: jenkins
#
# HTTPS port Jenkins is listening on.
# Default is disabled.
#
JENKINS_HTTPS_PORT=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Path to the keystore in JKS format (as created by the JDK 'keytool').
# Default is disabled.
#
JENKINS_HTTPS_KEYSTORE=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Password to access the keystore defined in JENKINS_HTTPS_KEYSTORE.
# Default is disabled.
#
JENKINS_HTTPS_KEYSTORE_PASSWORD=""
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# IP address Jenkins listens on for HTTPS requests.
# Default is disabled.
#
JENKINS_HTTPS_LISTEN_ADDRESS=""
## Type: integer(1:9)
## Default: 5
## ServiceRestart: jenkins
#
# Debug level for logs -- the higher the value, the more verbose.
# 5 is INFO.
#
JENKINS_DEBUG_LEVEL="5"
## Type: yesno
## Default: no
## ServiceRestart: jenkins
#
# Whether to enable access logging or not.
#
JENKINS_ENABLE_ACCESS_LOG="no"
## Type: integer
## Default: 100
## ServiceRestart: jenkins
#
# Maximum number of HTTP worker threads.
#
JENKINS_HANDLER_MAX="100"
## Type: integer
## Default: 20
## ServiceRestart: jenkins
#
# Maximum number of idle HTTP worker threads.
#
JENKINS_HANDLER_IDLE="20"
## Type: string
## Default: ""
## ServiceRestart: jenkins
#
# Pass arbitrary arguments to Jenkins.
# Full option list: java -jar jenkins.war --help
#
JENKINS_ARGS="--sessionTimeout=1440"
This file has been truncated, but you can view the full file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment