diff --git a/.gitignore b/.gitignore index 42b40c5..0ce61cb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ output-virtualbox-iso/* builds/* output-xfs/* output-ext4/* +ansible-playbooks diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..3bafba2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,24 @@ +#!groovy + +node('packer') { + stage 'Checkout' + + checkout scm + + stage 'Acquire ansible-playbooks' + + sh 'mkdir -p ansible-playbooks' + dir('ansible-playbooks'){ + git([ url: "https://github.internet2.edu/docker/ansible-playbooks.git", + branch: "shibboleth-production", credentialsId: "jenkins-github-access-token" ]) + } + + stage 'Validate' + + sh '/usr/local/bin/packer validate shibboleth-appliance.json' + + stage 'Build Appliance' + + sh '/usr/local/bin/packer build shibboleth-appliance.json' + +} diff --git a/README.md b/README.md index 3e8916f..350d35f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Introduction -This packer templates create vmware image of CentOS 7 with `.vmx` and `.ova`. In addition, there is an AMI you can create for AWS. You will need to have credentials setup according to [AWS credentials setup](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files) +This packer templates create vmware image of CentOS 7 with `.box` and `.ova`. In addition, there is an AMI you can create for AWS. You will need to have credentials setup according to [AWS credentials setup](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files) The OS versions are: @@ -11,12 +11,14 @@ The OS versions are: For all operating systems we generate images for - centos7.json will build: - - VmWare (user: packer/changeme1234) - VirtualBox (user: packer/changeme1234) - aws-centos7-base.json will build: - AMI for AWS (user: centos/centos) +- sibboleth-appliance.json will build: + - VirtualBox (user: centos/centos) + This template only is tested against 64 bit systems. With the following sizing requirements: ``` "vmx_data": { @@ -34,6 +36,16 @@ This template only is tested against 64 bit systems. With the following sizing r The templates are only tested with [packer](http://www.packer.io/downloads.html) 0.10.1 and later. +For local builds, you will need to provide a symbolic link to the `ansible-playbooks` directory for matching repo location. Make sure you have cloned and setup the [ansible-playbooks repo](https://github.internet2.edu/docker/ansible-playbooks). + +``` +# example +ln -s /path/to/ansible-playbooks ansible-playbooks + +# specific setup +ln -s ../ansible-playbooks ansible-playbooks +``` + ### Pre-Requisites for AWS / AMI import - IAM needs to be setup for the `vmimport` role per the [AWS guide](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/VMImportPrerequisites.html#vmimport-service-role). @@ -56,53 +68,12 @@ AMI build will require both `aws_access_key` and `aws_secret_key` to be setup wi packer build aws-centos7-base.json ``` -## Issues during build time - -If you experience issues with packer, please use `PACKER_LOG=1 packer ... ` to find the errors. - -## Author - - - Author:: Mason Packard () - -# License - -TBD -# Packer Image Builder for CentOS - -## Introduction - -This packer templates create vmware image of CentOS 7 with `.vmx` file type. - -The OS versions are: - - - Centos 7 - -For all operating systems we generate images for - - - VmWare (user: packer/changeme1234) - -This template only is tested against 64 bit systems. With the following sizing requirements: +Shibboleth Appliance build for `.ova`, `.box`, and AWS ami ``` - "vmx_data": { - "cpuid.coresPerSocket": "1", - "memsize": "512", - "numvcpus": "2" - } +# Build CentOS for ova, box, ami +packer build shibboleth-appliance.json ``` -``` - "disk_size": 81920 -``` - -## Requirements - -The templates are only tested with [packer](http://www.packer.io/downloads.html) 0.10.1 and later. - -## Run conversion process - - # Build CentOS VMWare image - PACKER_LOG=1 packer build centos7.json - ## Issues during build time If you experience issues with packer, please use `PACKER_LOG=1 packer ... ` to find the errors. @@ -114,3 +85,4 @@ If you experience issues with packer, please use `PACKER_LOG=1 packer ... ` to f # License TBD + diff --git a/ansible/main.yml b/ansible/main.yml deleted file mode 100644 index 71290a2..0000000 --- a/ansible/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- hosts: all - become: yes - gather_facts: yes - - tasks: - - name: "Run the Playbook" - shell: echo "<-------~ Playbook Start ~---------->" diff --git a/http/ks-ext4.cfg b/http/ks-ext4.cfg index c28f769..eb813e2 100644 --- a/http/ks-ext4.cfg +++ b/http/ks-ext4.cfg @@ -61,6 +61,8 @@ mkdir --mode=700 /home/centos/.ssh cat << EOF > /home/centos/.ssh/authorized_keys ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0F2Y68rs0DPofa9ZCJYxx9FG6Lzk+szeI6/c2P4C3yNWy1QvPDfUzFXGgPnb/O0EkI6s4qQ8Nt16GAfwdC4xvrZG5lpn++vBwEb4CxpF+23TsmQCi+DJjNgH4+XfBlGqplcjxJuMOrKrOO+wGuc7yetJ32b2wMNJUv0ijWpCiFp8fhs0a5+q4tq+6Q7LBlaIFTvjTP+YKh7JxAzG492m8TkbVQGnPpnTFI5OF5Q6t0Yqn87RZvVRvuU+jXXxSH7EHWbSpkXveElCC53o3MtunwTYtSkGDkAIF92Iw7eEX9d6hVsO4OXZPIgZn0oWNQQh8yyDYHB+4XQa1mQD8TS8f centos@centos.local +chown -R centos /home/centos/.ssh + EOF yum -y update diff --git a/http/ks-xfs.cfg b/http/ks-xfs.cfg index 6a1ae34..77c7449 100644 --- a/http/ks-xfs.cfg +++ b/http/ks-xfs.cfg @@ -32,7 +32,6 @@ reboot @core @development Tools openssh-clients -sudo openssl-devel readline-devel zlib-devel diff --git a/shibboleth-appliance.json b/shibboleth-appliance.json new file mode 100644 index 0000000..7e17656 --- /dev/null +++ b/shibboleth-appliance.json @@ -0,0 +1,82 @@ +{ + "min_packer_version": "0.8.6", + "description": "Shibboleth appliance ", + "variables": { + "profile": "xfs", + "disk_size": "8192", + "memory": "6122", + "cpus": "2", + "ssh_username": "centos", + "ssh_password": "centos", + "region": "us-west-1", + "timestamper": "{{timestamp}}", + "outputfile_name": "shibboleth-appliance-centos7" + }, + "provisioners": [ + { + "type": "shell", + "execute_command": "echo 'centos' | {{.Vars}} sudo -S -E bash '{{.Path}}'", + "script": "scripts/ansible.sh" + }, + { + "type": "ansible-local", + "playbook_dir": "ansible-playbooks", + "playbook_file": "ansible-playbooks/shibboleth-appliance-vbox.yml" + }, + { + "type": "shell", + "execute_command": "echo 'centos' | {{.Vars}} sudo -S -E bash '{{.Path}}'", + "script": "scripts/cleanup.sh" + } + ], + "builders": [ + { + "type": "virtualbox-iso", + "name": "shibboleth-appliance-centos7", + "vm_name": "shibboleth-appliance-centos7-{{user `profile`}}", + "headless": true, + "guest_os_type": "RedHat_64", + "disk_size": "{{user `disk_size`}}", + "vboxmanage": [ + ["modifyvm", "{{.Name}}", "--memory", "{{user `memory`}}"], + ["modifyvm", "{{.Name}}", "--cpus", "{{user `cpus`}}"] + ], + "iso_url": "http://mirror.vcu.edu/pub/gnu+linux/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso", + "iso_checksum": "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284", + "iso_checksum_type": "sha256", + "http_directory": "http", + "boot_command": [" text ks=http://{{.HTTPIP}}:{{.HTTPPort}}/ks-{{user `profile`}}.cfg"], + "boot_wait": "10s", + "ssh_username": "{{user `ssh_username`}}", + "ssh_password": "{{user `ssh_password`}}", + "ssh_port": 22, + "ssh_wait_timeout": "10000s", + "guest_additions_mode": "disable", + "shutdown_command": "sudo -S shutdown -P now", + "output_directory": "output-{{user `profile`}}", + "format": "ova" + } + ], + "post-processors": [ + { + "type": "compress", + "compression_level": "9", + "output": "builds/{{user `outputfile_name`}}-ova-{{user `timestamper`}}.tar" + }, + { + "type": "vagrant", + "compression_level": "9", + "output": "builds/{{user `outputfile_name`}}-vagrant-{{user `timestamper`}}.box" + }, + { + "type": "amazon-import", + "access_key": "{{user `aws_access_key`}}", + "secret_key": "{{user `aws_secret_key`}}", + "region": "{{user `region`}}", + "s3_bucket_name": "internet2-ami-import-us-west-1", + "tags": { + "Description": "packer amazon-import-shibboleth-appliance {{user `timestamper`}}" + } + } + ] +}