├── .gitignore ├── README.md ├── instance-templates ├── community-allinone.json ├── empty.json ├── repo-community-container.json ├── share.json └── solr.json ├── ks └── ks-centos.cfg ├── packer ├── builders │ ├── amazon-ebs.json │ ├── docker.json │ └── virtualbox-ovf.json ├── commands │ ├── common-env-vars.json │ ├── fetch-databags.json │ ├── nexus-upload.json │ ├── perform-git-release.json │ └── prepare-git-release.json ├── postprocessors │ └── vagrantbox.json └── provisioners │ ├── bento-vagrant.json │ ├── chef.json │ ├── image-cleanup.json │ ├── marketplace-ami-cleanup.json │ ├── network-interface.json │ ├── selinux-permissive.json │ ├── uninstall-cloudinit.json │ └── vagrant-key.json ├── scripts ├── chef-aws-cft-refarch-bootstrap.sh ├── chef-aws-community-bootstrap.sh ├── chef-aws-refarch-bootstrap.sh ├── chef-bootstrap.rb ├── chef-bootstrap.sh ├── chef │ ├── deploy-cookbook.sh │ ├── post-release-cookbook.sh │ ├── pre-release-cookbook.sh │ ├── s3-upload.sh │ └── test-cookbook.sh └── provisioning-libs.rb ├── stacks ├── community-allinone │ └── Vagrantfile └── enterprise-clustered │ └── Vagrantfile └── test ├── Vagrantfile.post ├── docker ├── Vagrantfile ├── build-docker-images.sh ├── check-docker-daemon.sh ├── install-docker.sh ├── install-packer.sh ├── install-vagrant.sh ├── pull-docker-images.sh └── run-docker-stack.sh └── old-stack-templates ├── community-allinone-docker.json ├── community-allinone-vagrantbox.json ├── community-allinone.json ├── community-allinone.json.yamlexample ├── community-allinone.vagrant.rb ├── enterprise-clustered.json └── enterprise-clustered.vagrant.rb /.gitignore: -------------------------------------------------------------------------------- 1 | **/alf_data_shared 2 | **/maven_repos/private.json 3 | *.lock 4 | dev/Berksfile.dev 5 | .vagrant 6 | *.box 7 | Gemfile.lock 8 | vendor-cookbooks 9 | packer_cache 10 | output-virtualbox-iso 11 | *.lic 12 | *.tar 13 | bootstrap-data 14 | license 15 | alf_data 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Alfresco SPK 2 | 3 | Alfresco SPK is a toolset that can be used by stack operators (Devops/Architects/Engineers, Support, QA, Sales, Marketing, ...) to define Alfresco immutable Images, testing them locally first, also for arbitrarily complex architectures. 4 | 5 | It allows you to: 6 | 7 | - Run an arbitrarily complex stack locally 8 | - Build (immutable) image(s) with the exact same provisioning logic used for local run 9 | - Test immutable images locally 10 | - Run a stack on any orchestration tool with the same provisioning logic used for local runs 11 | 12 | ### How to contribute 13 | To avoid any problem on master, we are implementing git-flow. 14 | To contribute, follow this: 15 | 16 | - Fork this repository 17 | - Make your changes 18 | - Test your changes 19 | - Open a pull request to develop 20 | 21 | 22 | ### External References 23 | 24 | - [BeeCon presentation](https://www.youtube.com/watch?v=-L1CjPA2R6E) 25 | - [Alfresco Tech Talk Live #95](https://www.youtube.com/watch?v=y1ZbVvy_Evc) 26 | - [Alfresco SPK Presentation at AlfrescoDay](http://www.slideshare.net/m.pillitu/alfresco-spkalfrescoday) 27 | -------------------------------------------------------------------------------- /instance-templates/community-allinone.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "community-allinone", 3 | "alfresco" : { 4 | "version" : "5.1.f", 5 | "components" : ["haproxy","nginx","tomcat","transform","repo","share","solr","mysql"], 6 | "start_service" : false, 7 | "public_protocol" : "http", 8 | "ssl_enabled" : false, 9 | "public_portssl" : "80" 10 | }, 11 | "nginx" : { 12 | "disable_nginx_init" : true, 13 | "use_nossl_config" : true 14 | }, 15 | "run_list": ["alfresco::default"], 16 | "_images" : { 17 | "provisioners" : { 18 | "chef-alfresco" : "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/packer/provisioners/chef.json", 19 | "vagrant-key" : "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/packer/provisioners/vagrant-key.json", 20 | "image-cleanup" : "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/packer/provisioners/image-cleanup.json", 21 | "uninstall-cloudinit" : "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/packer/provisioners/uninstall-cloudinit.json" 22 | }, 23 | "builders" : { 24 | "virtualbox-ovf" : "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/packer/builders/virtualbox-ovf.json" 25 | }, 26 | "postprocessors" : { 27 | "vagrantbox" : "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/packer/postprocessors/vagrantbox.json" 28 | }, 29 | "variables" : { 30 | "chef_version" : "12.7.2", 31 | "chef_prevent_sudo" : "false", 32 | "vagrant_output_file" : "alfresco-community-test-{{timestamp}}.box", 33 | "iso_url" : "http://centos.mirror.transip.nl/7/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso", 34 | "iso_checksum" : "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284", 35 | "iso_checksum_type" : "sha256", 36 | "ssh_username" : "root", 37 | "ssh_password" : "vagrant", 38 | "ks_path" : "./ks.cfg", 39 | "http_directory" : "./", 40 | "headless" : "true", 41 | "guest_os_type" : "RedHat_64", 42 | "output_directory": "alfresco-community-vbox-output-{{timestamp}}", 43 | "keep_ovf_file" : "true", 44 | "vm_name": "alfresco-community-test-{{timestamp}}", 45 | "run_list" : "alfresco::default" 46 | } 47 | }, 48 | "_local" : { 49 | "ip" : "192.168.33.43", 50 | "ram" : "4096", 51 | "cpus" : "2" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /instance-templates/empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "empty" 3 | } 4 | -------------------------------------------------------------------------------- /instance-templates/repo-community-container.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "repo-community-container", 3 | "nginx" : { 4 | "use_nossl_config" : true, 5 | "disable_nginx_init" : true 6 | }, 7 | "alfresco" : { 8 | "components" : ["tomcat","transform","repo","aos","googledocs"], 9 | "skip_certificate_creation" : true, 10 | "public_protocol" : "http", 11 | "public_portssl" : "80" 12 | }, 13 | "run_list": ["alfresco::default"] 14 | } 15 | -------------------------------------------------------------------------------- /instance-templates/share.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "enterprise-share", 3 | "nginx" : { 4 | "use_nossl_config" : true 5 | }, 6 | "alfresco" : { 7 | "version" : "5.0.2.5", 8 | "edition" : "enterprise", 9 | "components" : ["haproxy","nginx","tomcat","transform","repo","share","aos","mysql"], 10 | "restart_services" : ["tomcat-alfresco","tomcat-share"], 11 | "properties" : {} 12 | }, 13 | "artifact-deployer" : { 14 | "maven" : { 15 | "repositories" : { 16 | "private" : { 17 | "url" : "https://artifacts.alfresco.com/nexus/content/repositories/private", 18 | "username" : "{{ user `private_maven_repo_username`}}", 19 | "password" : "{{ user `private_maven_repo_password`}}" 20 | } 21 | } 22 | } 23 | }, 24 | "run_list": ["alfresco::default"], 25 | "_local" : { 26 | "ip" : "192.168.33.51", 27 | "ram" : "4096", 28 | "cpus" : "2" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /instance-templates/solr.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "enterprise-solr", 3 | "alfresco" : { 4 | "skip_certificate_creation" : true, 5 | "version" : "5.0.2.5", 6 | "edition" : "enterprise", 7 | "components" : ["tomcat","repo","solr"], 8 | "restart_services" : ["tomcat-alfresco","tomcat-solr"], 9 | "properties" : {} 10 | }, 11 | "artifact-deployer" : { 12 | "maven" : { 13 | "repositories" : { 14 | "private" : { 15 | "url" : "https://artifacts.alfresco.com/nexus/content/repositories/private", 16 | "username" : "{{ user `private_maven_repo_username`}}", 17 | "password" : "{{ user `private_maven_repo_password`}}" 18 | } 19 | } 20 | } 21 | }, 22 | "run_list": ["alfresco::default"], 23 | "_local" : { 24 | "ip" : "192.168.33.52", 25 | "ram" : "2048", 26 | "cpus" : "1" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ks/ks-centos.cfg: -------------------------------------------------------------------------------- 1 | # Copied from https://github.com/chef/bento/blob/master/http/centos-7.1/ks.cfg 2 | 3 | install 4 | cdrom 5 | lang en_US.UTF-8 6 | keyboard us 7 | network --bootproto=dhcp 8 | rootpw vagrant 9 | firewall --disabled 10 | selinux --permissive 11 | timezone UTC 12 | unsupported_hardware 13 | bootloader --location=mbr 14 | text 15 | skipx 16 | zerombr 17 | clearpart --all --initlabel 18 | autopart 19 | auth --enableshadow --passalgo=sha512 --kickstart 20 | firstboot --disabled 21 | reboot 22 | user --name=vagrant --plaintext --password vagrant 23 | 24 | %packages --nobase --ignoremissing --excludedocs 25 | # vagrant needs this to copy initial files via scp 26 | openssh-clients 27 | sudo 28 | kernel-headers 29 | kernel-devel 30 | gcc 31 | make 32 | perl 33 | wget 34 | nfs-utils 35 | net-tools 36 | bzip2 37 | -fprintd-pam 38 | -intltool 39 | 40 | # unnecessary firmware 41 | -aic94xx-firmware 42 | -atmel-firmware 43 | -b43-openfwwf 44 | -bfa-firmware 45 | -ipw2100-firmware 46 | -ipw2200-firmware 47 | -ivtv-firmware 48 | -iwl100-firmware 49 | -iwl105-firmware 50 | -iwl135-firmware 51 | -iwl1000-firmware 52 | -iwl2000-firmware 53 | -iwl2030-firmware 54 | -iwl3160-firmware 55 | -iwl3945-firmware 56 | -iwl4965-firmware 57 | -iwl5000-firmware 58 | -iwl5150-firmware 59 | -iwl6000-firmware 60 | -iwl6000g2a-firmware 61 | -iwl6000g2b-firmware 62 | -iwl6050-firmware 63 | -iwl7260-firmware 64 | -libertas-usb8388-firmware 65 | -libertas-sd8686-firmware 66 | -libertas-sd8787-firmware 67 | -ql2100-firmware 68 | -ql2200-firmware 69 | -ql23xx-firmware 70 | -ql2400-firmware 71 | -ql2500-firmware 72 | -rt61pci-firmware 73 | -rt73usb-firmware 74 | -xorg-x11-drv-ati-firmware 75 | -zd1211-firmware 76 | %end 77 | 78 | %post 79 | # sudo 80 | echo "%vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/vagrant 81 | sed -i "s/^[^#].*requiretty/#Defaults requiretty/" /etc/sudoers 82 | %end 83 | -------------------------------------------------------------------------------- /packer/builders/amazon-ebs.json: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "amazon-ebs", 3 | "ssh_pty" : "true", 4 | "access_key" : "{{user `access_key`}}", 5 | "secret_key" : "{{user `secret_key`}}", 6 | "vpc_id" : "{{user `vpc_id`}}", 7 | "region" : "{{user `region`}}", 8 | "source_ami" : "{{user `source_ami`}}", 9 | "instance_type" : "{{user `instance_type`}}", 10 | "ssh_username" : "{{user `ssh_username`}}", 11 | "security_group_ids" : "{{user `security_group_ids`}}", 12 | "ami_name" : "{{user `ami_name`}}", 13 | "ami_description" : "{{user `ami_description`}}", 14 | "ami_virtualization_type" : "hvm", 15 | "ami_users" : "{{user `ami_users`}}", 16 | "enhanced_networking" : "true", 17 | "associate_public_ip_address": "{{user `associate_public_ip_address`}}", 18 | "subnet_id": "{{user `subnet_id`}}", 19 | "ami_block_device_mappings" : [ 20 | { 21 | "device_name" : "/dev/sda1", 22 | "volume_size" : "{{user `root_disk_size`}}", 23 | "delete_on_termination" : "{{user `root_delete_on_termination`}}" 24 | }, 25 | { 26 | "device_name" : "/dev/sdb", 27 | "virtual_name" : "ephemeral0" 28 | }, 29 | { 30 | "device_name" : "/dev/sdc", 31 | "virtual_name" : "ephemeral1" 32 | } 33 | ], 34 | "launch_block_device_mappings" : [ 35 | { 36 | "device_name" : "/dev/sda1", 37 | "volume_size" : "{{user `ami_root_disk_size`}}", 38 | "delete_on_termination" : "true" 39 | } 40 | ] 41 | } 42 | -------------------------------------------------------------------------------- /packer/builders/docker.json: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "docker", 3 | "image": "centos", 4 | "export_path": "image.tar" 5 | } 6 | -------------------------------------------------------------------------------- /packer/builders/virtualbox-ovf.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "virtualbox-iso", 3 | "output_directory" : "{{user `output_directory`}}", 4 | "vm_name" : "{{user `vm_name`}}", 5 | "iso_url": "{{user `iso_url`}}", 6 | "iso_checksum": "{{user `iso_checksum`}}", 7 | "iso_checksum_type": "{{user `iso_checksum_type`}}", 8 | "http_directory": "{{user `http_directory`}}", 9 | "ssh_username": "{{user `ssh_username`}}", 10 | "ssh_password": "{{user `ssh_password`}}", 11 | "guest_os_type": "{{user `guest_os_type`}}", 12 | "boot_command": [ 13 | " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/{{user `ks_path`}}" 14 | ], 15 | "guest_additions_mode" : "disable", 16 | "headless": "{{user `headless`}}", 17 | "shutdown_command": "echo '{{user `ssh_password`}}' | sudo -S /sbin/halt -p" 18 | } 19 | -------------------------------------------------------------------------------- /packer/commands/common-env-vars.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["LC_ALL","en_US.UTF-8"], 3 | ["LANG","en_US.UTF-8"], 4 | ["GIT_PREFIX","git@github.com"], 5 | ["GIT_ACCOUNT_NAME","`echo ${GIT_REPO%????} | cut -d \"/\" -f 4`"], 6 | ["CURRENT_VERSION","`cat metadata.rb| grep version|awk '{print $2}' | tr -d \\\"`"], 7 | ["INCREMENTED_VERSION","`echo $CURRENT_VERSION | awk -F'[.]' '{print $1 \".\" $2 \".\" $3+1}'`"], 8 | ["MVN_REPO_CREDS_ID","alfresco-internal"], 9 | ["MVN_REPO_ID","internal-releases"], 10 | ["MVN_REPO_HOST","https://artifacts.alfresco.com/nexus"], 11 | ["MVN_REPO_URL","$MVN_REPO_HOST/content/repositories/$MVN_REPO_ID"], 12 | ["GROUP_ID","org.alfresco.devops"], 13 | ["MVN_INTERNAL_REPO_URL","$MVN_REPO_URL/content/repositories/$MVN_REPO_ID"], 14 | ["ARTIFACT_ID","=`echo ${GIT_REPO%????} | cut -d \"/\" -f 5`"], 15 | ["CURRENT_VERSION_SUFFIX","-SNAPSHOT"], 16 | ["CURRENT_VERSION","${CURRENT_VERSION}${CURRENT_VERSION_SUFFIX}"], 17 | ["GIT_PROJECT_NAME","$ARTIFACT_ID"], 18 | ["DATABAGS_ARTIFACTID","alfresco-databags"], 19 | ["DATABAGS_GROUPID","org.alfresco.devops"], 20 | ["DATABAGS_VERSION","0.2.8"], 21 | ["DATABAGS_PATH","~/.vagrant.d/data/packer-plugin/data_bags.tar.gz"], 22 | ["DATABAGS_FOLDER_PATH","~/.vagrant.d/data/packer-plugin/data_bags"], 23 | ["KS_FILE_URL","https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/ks/ks-centos.cfg"], 24 | ["BERKS_COOKBOOK_URL","file://$PWD/berks-cookbooks.tar.gz"] 25 | ] 26 | -------------------------------------------------------------------------------- /packer/commands/fetch-databags.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["Set Pre Run Environment Variables","export DATABAGS_FOLDER_PATH=~/.vagrant.d/data/packer-plugin/data_bags"], 3 | ["Fetching Chef Databags artifact","mvn dependency:get -DremoteRepositories=$MVN_REPO_CREDS_ID::::$MVN_REPO_URL -DartifactId=$DATABAGS_ARTIFACTID -DgroupId=$DATABAGS_GROUPID -Dversion=$DATABAGS_VERSION -Dpackaging=tar.gz -Ddest=$DATABAGS_PATH ; tar xzf $DATABAGS_PATH -C ~/.vagrant.d/data/packer-plugin"] 4 | ] 5 | -------------------------------------------------------------------------------- /packer/commands/nexus-upload.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["Deploy Berkshelf artifact to Nexus","mvn deploy:deploy-file -Dfile=$(echo *.tar.gz) -DrepositoryId=$MVN_REPO_CREDS_ID -Durl=$MVN_INTERNAL_REPO_URL -DgroupId=$GROUP_ID -DartifactId=$ARTIFACT_ID -Dversion=$CURRENT_VERSION -Dpackaging=tar.gz"] 3 | ] 4 | -------------------------------------------------------------------------------- /packer/commands/perform-git-release.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["Increment Cookbook Version"," sed \"s/$CURRENT_VERSION/$INCREMENTED_VERSION/\" metadata.rb > metadata.rb.tmp ; rm -f metadata.rb ; mv metadata.rb.tmp metadata.rb"], 3 | ["Update Cookbook Changelog","if [ -n \"$GIT_TOKEN\" ] ; then github_changelog_generator -u Alfresco -p chef-alfresco -t $GIT_TOKEN ; sed -i '/- Update /d' ./CHANGELOG.md ; fi"], 4 | ["Push Git tag remotely", "git push origin --tags"], 5 | ["Release Cookbook in Git", "git stash ; git pull origin master ; git stash pop ; git add metadata.rb ; git add *.md ; git commit -m Bumping version to v$CURRENT_VERSION ; git push origin master"] 6 | ] 7 | -------------------------------------------------------------------------------- /packer/commands/prepare-git-release.json: -------------------------------------------------------------------------------- 1 | [ 2 | ["Setting git remote","git remote set-url origin $GIT_PREFIX:$GIT_ACCOUNT_NAME/$GIT_PROJECT_NAME.git"], 3 | ["Create local Git tag","if git tag -d v$CURRENT_VERSION ; then echo \"Removed existing tag v$CURRENT_VERSION\" ; fi ; git tag -a \"v$CURRENT_VERSION\" -m releasing \"v$CURRENT_VERSION\""] 4 | ] 5 | -------------------------------------------------------------------------------- /packer/postprocessors/vagrantbox.json: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "vagrant", 3 | "output" : "{{user `vagrant_output_file`}}", 4 | "compression_level" : 7, 5 | "keep_input_artifact" : true 6 | } 7 | -------------------------------------------------------------------------------- /packer/provisioners/bento-vagrant.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "shell", 3 | "inline": [ 4 | "echo 'invoking metadata.sh' && curl -L https://raw.githubusercontent.com/chef/bento/2.2.2/scripts/common/metadata.sh | bash -s", 5 | "echo 'invoking sshd.sh' && curl -L https://raw.githubusercontent.com/chef/bento/2.2.2/scripts/common/sshd.sh | bash -s", 6 | "echo 'invoking networking.sh' && curl -L https://raw.githubusercontent.com/chef/bento/2.2.2/scripts/centos/networking.sh | bash -s", 7 | "echo 'invoking vagrant.sh' && curl -L https://raw.githubusercontent.com/chef/bento/2.2.2/scripts/common/vagrant.sh | bash -s", 8 | "echo 'invoking cleanup.sh' && curl -L https://raw.githubusercontent.com/chef/bento/2.2.2/scripts/centos/cleanup.sh | bash -s", 9 | "echo 'invoking minimize.sh' && curl -L https://raw.githubusercontent.com/chef/bento/2.2.2/scripts/common/minimize.sh | bash -s" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /packer/provisioners/chef.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "chef-solo", 3 | "execute_command" : "cd /tmp/packer-chef-solo && ln -s cookbooks-0 cookbooks && {{if .Sudo}}sudo {{end}}chef-client --no-color -z -j {{.JsonPath}}", 4 | "install_command": "{{if .Sudo}}sudo {{end}}bash -c 'curl -L https://www.opscode.com/chef/install.sh| bash -s -- -v {{ user `chef_version` }}'", 5 | "prevent_sudo": false, 6 | "skip_install": false, 7 | "run_list": ["{{user `run_list_item`}}"] 8 | } 9 | -------------------------------------------------------------------------------- /packer/provisioners/image-cleanup.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "shell", 3 | "inline": [ 4 | "sudo yum -y clean all", 5 | "sudo find /var/log -type f -delete", 6 | "sudo find /tmp -type f -delete", 7 | "sudo rm -rf /root/.aws", 8 | "sudo rm -rf /usr/local/maven/conf/settings.xml", 9 | "sudo rm -fr /root/.m2", 10 | "sudo systemctl stop postfix", 11 | "sudo systemctl disable postfix", 12 | "sudo yum -y remove php-*", 13 | "sudo yum -y remove gcc-*", 14 | "sudo find /root /home -name '.*history' -delete" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /packer/provisioners/marketplace-ami-cleanup.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "shell", 3 | "inline": [ 4 | "sudo find / -name authorized_keys -delete", 5 | "sudo find /root/ /home/*/ -name .cvspass -delete" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /packer/provisioners/network-interface.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "shell", 3 | "inline": [ 4 | "sudo sed -i 's/crashkernel\=auto/net.ifnames\=0\ crashkernel\=auto/g' /etc/default/grub", 5 | "sudo grub2-mkconfig -o /boot/grub2/grub.cfg" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /packer/provisioners/selinux-permissive.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "shell", 3 | "inline": ["setenforce 0"] 4 | } 5 | -------------------------------------------------------------------------------- /packer/provisioners/uninstall-cloudinit.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "shell", 3 | "inline": [ 4 | "yum -y erase cloud-init" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /packer/provisioners/vagrant-key.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "shell", 3 | "inline": [ 4 | "mkdir -p /home/vagrant/.ssh", 5 | "chmod 0700 /home/vagrant/.ssh", 6 | "yum install -y wget bzip2", 7 | "wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/vagrant/.ssh/authorized_keys", 8 | "chmod 0600 /home/vagrant/.ssh/authorized_keys", 9 | "chown -R vagrant /home/vagrant/.ssh" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /scripts/chef-aws-cft-refarch-bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export WORK_DIR=/tmp/chef-bootstrap 4 | mkdir -p $WORK_DIR 5 | 6 | # Use the Chef Alfresco version of your choice, also SNAPSHOT versions 7 | # export COOKBOOKS_URL="https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/devops/chef-alfresco/0.6.9/chef-alfresco-0.6.9.tar.gz" 8 | # DATABAGS_URL="..." 9 | 10 | export CHEF_NODE_NAME=allinone 11 | export CHEF_INSTANCE_TEMPLATE=https://raw.githubusercontent.com/alfresco/alfresco-spk/master/instance-templates/community-allinone.json 12 | 13 | # Manage Alfresco License retrieval 14 | mkdir /opt/alflicense 15 | curl -L ",{"Ref": "AlfrescoTrialLicense"}," -o /opt/alflicense/license.lic 16 | 17 | # Open SELinux restrictions to allow haproxy/nginx to run 18 | semanage port -a -t http_port_t -p tcp 2100 19 | semanage permissive -a httpd_t 20 | semanage permissive -a haproxy_t 21 | 22 | # Define Local Variables in YAML format, to avoid JSON escaping nightmares 23 | CHEF_LOCAL_YAML_VARS_URL=$WORK_DIR/local-vars.yaml 24 | cat > $CHEF_LOCAL_YAML_VARS_URL << "EOF" 25 | --- 26 | run_list: ["alfresco::redeploy"] 27 | artifact-deployer: 28 | maven: 29 | repositories: 30 | private: 31 | username: '{"Ref": "ArtifactRepoUsername"}' 32 | password: '{"Ref": "ArtifactRepoPassword"}' 33 | alfresco: 34 | public_hostname: '{"Fn::GetAtt": ["ElasticLoadBalancer","DNSName"]}' 35 | properties: 36 | s3.accessKey: '{"Ref":"CfnKeys"}' 37 | s3.secretKey: '{"Fn::GetAtt":["CfnKeys","SecretAccessKey"]}' 38 | hz_aws_access_key: '{"Ref":"CfnKeys"}' 39 | hz_aws_secret_key: '{"Fn::GetAtt":["CfnKeys","SecretAccessKey"]}' 40 | db.host: '{"Fn::GetAtt": ["RDSDBInstance","Endpoint.Address"]}' 41 | db.dbname: '{"Ref": "RDSDBName"}' 42 | db.username: '{"Ref": "RDSUsername"}' 43 | db.password: '{"Ref": "RDSPassword"}' 44 | s3.bucketName: '{"Ref": "S3BucketName"}' 45 | s3.bucketLocation: '{"Ref": "AWS::Region"}' 46 | s3.bucketRegion: '{"Ref": "AWS::Region"}' 47 | s3service.s3-endpoint: 's3-{"Ref": "AWS::Region"}.amazonaws.com' 48 | hz_aws_sg_name: 'AWS_SG_NAME' 49 | EOF 50 | 51 | export CHEF_LOCAL_YAML_VARS_URL=file://$CHEF_LOCAL_YAML_VARS_URL 52 | 53 | # Fetch files to install alfresco 54 | curl -L https://raw.githubusercontent.com/alfresco/alfresco-spk/master/scripts/provisioning-libs.rb > provisioning-libs.rb 55 | curl -L https://raw.githubusercontent.com/alfresco/alfresco-spk/master/scripts/chef-bootstrap.rb > chef-bootstrap.rb 56 | 57 | # Run Alfresco installation 58 | yum install -y ruby 59 | gem install json-merge_patch 60 | ruby chef-bootstrap.rb 61 | -------------------------------------------------------------------------------- /scripts/chef-aws-community-bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Bootstraps "Alfresco Community 5.1.c-EA - Allinone Server" AMI, 4 | # built with Alfresco SPK. 5 | # 6 | # Copy/paste this script into Userdata configuration of 7 | # any EC2 instance launch; as such, it can be reused in 8 | # any cloudformation or AWS-specific orchestration tool; 9 | # more info on 10 | # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html 11 | 12 | export WORK_DIR=/tmp/chef-bootstrap 13 | mkdir -p $WORK_DIR 14 | 15 | export CHEF_NODE_NAME=allinone 16 | export CHEF_INSTANCE_TEMPLATE=https://raw.githubusercontent.com/alfresco/alfresco-spk/master/instance-templates/community-allinone.json 17 | 18 | export FQDN=$(curl http://169.254.169.254/latest/meta-data/public-hostname) 19 | 20 | # Open SELinux restrictions to allow haproxy/nginx to run 21 | # semanage port -a -t http_port_t -p tcp 2100 22 | # semanage permissive -a httpd_t 23 | # semanage permissive -a haproxy_t 24 | 25 | # Define Local Variables in YAML format, to avoid JSON escaping nightmares 26 | CHEF_LOCAL_YAML_VARS_URL=$WORK_DIR/local-vars.yaml 27 | cat > $CHEF_LOCAL_YAML_VARS_URL << ENDOFCONTENT 28 | --- 29 | run_list: ["alfresco::redeploy"] 30 | alfresco: 31 | public_hostname: '$FQDN' 32 | ENDOFCONTENT 33 | 34 | export CHEF_LOCAL_YAML_VARS_URL=file://$CHEF_LOCAL_YAML_VARS_URL 35 | 36 | # Fetch files to install alfresco 37 | curl -L https://raw.githubusercontent.com/alfresco/alfresco-spk/master/scripts/provisioning-libs.rb > provisioning-libs.rb 38 | curl -L https://raw.githubusercontent.com/alfresco/alfresco-spk/master/scripts/chef-bootstrap.rb > chef-bootstrap.rb 39 | 40 | # Run Alfresco installation 41 | yum install -y ruby 42 | gem install json-merge_patch 43 | ruby chef-bootstrap.rb 44 | -------------------------------------------------------------------------------- /scripts/chef-aws-refarch-bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Bootstraps "Alfresco Community 5.1.c-EA - Allinone Server" AMI, 4 | # built with Alfresco SPK. 5 | # 6 | # Copy/paste this script into Userdata configuration of 7 | # any EC2 instance launch; as such, it can be reused in 8 | # any cloudformation or AWS-specific orchestration tool; 9 | # more info on 10 | # http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html 11 | 12 | export WORK_DIR=/tmp/chef-bootstrap 13 | mkdir -p $WORK_DIR 14 | 15 | export CHEF_NODE_NAME=allinone 16 | export CHEF_INSTANCE_TEMPLATE=https://raw.githubusercontent.com/alfresco/alfresco-spk/master/instance-templates/community-allinone.json 17 | 18 | export FQDN=$(curl http://169.254.169.254/latest/meta-data/public-hostname) 19 | 20 | # Open SELinux restrictions to allow haproxy/nginx to run 21 | # semanage port -a -t http_port_t -p tcp 2100 22 | # semanage permissive -a httpd_t 23 | # semanage permissive -a haproxy_t 24 | 25 | # Define Local Variables in YAML format, to avoid JSON escaping nightmares 26 | CHEF_LOCAL_YAML_VARS_URL=$WORK_DIR/local-vars.yaml 27 | cat > $CHEF_LOCAL_YAML_VARS_URL << ENDOFCONTENT 28 | --- 29 | run_list: ["alfresco::redeploy"] 30 | alfresco: 31 | public_hostname: '$FQDN' 32 | ENDOFCONTENT 33 | 34 | export CHEF_LOCAL_YAML_VARS_URL=file://$CHEF_LOCAL_YAML_VARS_URL 35 | 36 | # Fetch files to install alfresco 37 | curl -L https://raw.githubusercontent.com/alfresco/alfresco-spk/master/scripts/provisioning-libs.rb > provisioning-libs.rb 38 | curl -L https://raw.githubusercontent.com/alfresco/alfresco-spk/master/scripts/chef-bootstrap.rb > chef-bootstrap.rb 39 | 40 | # Run Alfresco installation 41 | yum install -y ruby 42 | gem install json-merge_patch 43 | ruby chef-bootstrap.rb 44 | -------------------------------------------------------------------------------- /scripts/chef-bootstrap.rb: -------------------------------------------------------------------------------- 1 | # chef-bootstrap.rb 2 | # 3 | # -*- mode: ruby -*- 4 | # vi: set ft=ruby : 5 | require_relative 'provisioning-libs' 6 | 7 | params = getEnvParams() 8 | 9 | workDir = ENV['WORK_DIR'] || "/tmp/chef-bootstrap" 10 | downloadCmd = params['downloadCmd'] 11 | cookbooksUrl = params['cookbooksUrl'] 12 | dataBagsUrl = params['dataBagsUrl'] 13 | 14 | chefNodeName = params['chefNodeName'] 15 | instanceTemplate = params['chefInstanceTemplate'] 16 | localYamlVarsUrl = params['chefLocalYamlVarsUrl'] 17 | localJsonVars = params['chefLocalJsonVars'] 18 | 19 | downloadArtifact(workDir, downloadCmd, cookbooksUrl, "cookbooks") 20 | downloadArtifact(workDir, downloadCmd, dataBagsUrl, "databags") 21 | 22 | downloadNodeDefinition(workDir, downloadCmd, chefNodeName, instanceTemplate, localYamlVarsUrl, localJsonVars) 23 | 24 | installChef() 25 | 26 | runChef(workDir, params['chefLogLevel'], params['chefLogFile'], "#{workDir}/attributes-#{chefNodeName}.json") 27 | -------------------------------------------------------------------------------- /scripts/chef-bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Use the Chef Alfresco version of your choice, also SNAPSHOT versions 4 | # export COOKBOOKS_URL="https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/devops/chef-alfresco/0.6.11/chef-alfresco-0.6.11.tar.gz" 5 | # DATABAGS_URL="..." 6 | 7 | export WORK_DIR=/tmp/chef-bootstrap 8 | export CHEF_NODE_NAME=allinone 9 | export CHEF_INSTANCE_TEMPLATE=https://raw.githubusercontent.com/alfresco/alfresco-spk/master/instance-templates/community-allinone.json 10 | export CHEF_LOCAL_YAML_VARS_URL=file://$WORK_DIR/local-vars.yaml 11 | 12 | mkdir -p $WORK_DIR 13 | 14 | # Define Local Variables in YAML format, to avoid JSON escaping nightmares 15 | CHEF_LOCAL_YAML_VARS_URL= 16 | cat > $WORK_DIR/local-vars.yaml << "EOF" 17 | --- 18 | alfresco: 19 | install_fonts: false 20 | nginx: 21 | use_nossl_config: true 22 | EOF 23 | 24 | # Fetch files to install alfresco 25 | curl -L https://raw.githubusercontent.com/alfresco/alfresco-spk/master/scripts/provisioning-libs.rb > provisioning-libs.rb 26 | curl -L https://raw.githubusercontent.com/alfresco/alfresco-spk/master/scripts/chef-bootstrap.rb > chef-bootstrap.rb 27 | 28 | # Only for allinone, this is necessary to avoid mysql to fail 29 | setenforce 0 30 | 31 | yum install -y ruby 32 | gem install json-merge_patch 33 | ruby chef-bootstrap.rb 34 | -------------------------------------------------------------------------------- /scripts/chef/deploy-cookbook.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # export MVN_REPO_CREDS_ID=my-repo-credentials-id 4 | # export MVN_REPO_URL=http://artifacts.acme.com/nexus 5 | # export GROUP_ID=my.acme.project 6 | 7 | # Set one of the following variables 8 | # export GIT_REPO="https://github.com/foo/bar.git" 9 | # export ARTIFACT_ID="bar" 10 | 11 | # Fixes issue https://github.com/berkshelf/berkshelf-api/issues/112 12 | export LC_ALL=en_US.UTF-8 13 | export LANG=en_US.UTF-8 14 | 15 | export PATH=/usr/local/packer:$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH 16 | 17 | # If ARTIFACT_ID is not set, extract it from GIT_REPO 18 | # Right now it only supports HTTP Git urls 19 | if [ -z "$ARTIFACT_ID" ]; then 20 | export ARTIFACT_ID=`echo ${GIT_REPO%????} | cut -d "/" -f 5` 21 | echo "[deploy-cookbook.sh] Setting ARTIFACT_ID=$ARTIFACT_ID" 22 | else 23 | echo "[deploy-cookbook.sh] ARTIFACT_ID=$ARTIFACT_ID" 24 | fi 25 | 26 | buildArtifact () { 27 | # Using a gem installed berks won't work, because of the dependencies. 28 | 29 | # gem_installer () { 30 | # local gem=$1 31 | 32 | # gem list --no-installed ${gem} &>> /dev/null 33 | # if [ $? == 0 ] 34 | # then 35 | # gem_user_install () { gem install --no-rdoc --no-ri --user-install $*; } 36 | # gem_user_install ${gem} 37 | # fi 38 | # } 39 | 40 | # # Coarse grained. 41 | # set +e 42 | # gem_installer berkshelf 43 | # set -e 44 | 45 | # Ensure we're using system defined berks 46 | local __berks=/usr/bin/berks 47 | 48 | if [ -s Berksfile ]; then 49 | echo "[deploy-cookbook.sh] Building Chef artifact with Berkshelf" 50 | rm -rf Berksfile.lock *.tar.gz; ${__berks} package berks-cookbooks.tar.gz 51 | elif [ -d data_bags ]; then 52 | echo "[deploy-cookbook.sh] Building Chef Databags artifact" 53 | rm -rf *.tar.gz; tar cfvz alfresco-databags.tar.gz ./data_bags 54 | fi 55 | } 56 | 57 | getCurrentVersion () { 58 | local version=$(grep ^version metadata.rb | awk '{print $2}' | tr -d \'\") 59 | echo ${version} 60 | } 61 | 62 | deploy () { 63 | echo "[deploy-cookbook.sh] Deploy $1" 64 | local repo_name=$MVN_REPO_ID 65 | 66 | mvn deploy:deploy-file -Dfile=$(echo *.tar.gz) -DrepositoryId=$MVN_REPO_CREDS_ID -Durl=$MVN_REPO_URL/content/repositories/$repo_name -DgroupId=$GROUP_ID -DartifactId=$ARTIFACT_ID -Dversion=$1 -Dpackaging=tar.gz 67 | } 68 | 69 | run () { 70 | # Quit on failures 71 | set -e 72 | local suffix=$1 73 | buildArtifact 74 | local current_version=$(getCurrentVersion) 75 | deploy "$current_version$suffix" 76 | } 77 | 78 | suffix=$1 79 | run $suffix 80 | -------------------------------------------------------------------------------- /scripts/chef/post-release-cookbook.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | getCurrentVersion () { 4 | version=$(grep version metadata.rb | awk '{print $2}' | tr -d \'\") 5 | echo ${version} 6 | } 7 | 8 | getIncrementedVersion () { 9 | version=$(getCurrentVersion) 10 | echo $version | awk -F'[.]' '{print $1 "." $2 "." $3+1}' 11 | } 12 | 13 | incrementVersion () { 14 | export currentVersion=$(getCurrentVersion) 15 | export nextVersion=$(getIncrementedVersion) 16 | 17 | echo "[post-release-cookbook.sh] Incrementing version from $currentVersion to $nextVersion" 18 | 19 | sed "s/$currentVersion/$nextVersion/" metadata.rb > metadata.rb.tmp 20 | rm -f metadata.rb 21 | mv metadata.rb.tmp metadata.rb 22 | 23 | # TODO - enable it when autoconf is installed 24 | if [ -n "$GIT_TOKEN" ] 25 | then 26 | echo "[post-release-cookbook.sh] Adding $currentVersion to CHANGELOG.md" 27 | github_changelog_generator -u Alfresco -p $GIT_PROJECT_NAME -t $GIT_TOKEN 28 | sed -i '/- Update /d' ./CHANGELOG.md 29 | fi 30 | } 31 | 32 | run() { 33 | echo "[post-release-cookbook.sh] Pushing $(getCurrentVersion) tag to github (origin)" 34 | git push origin --tags 35 | incrementVersion 36 | echo "[post-release-cookbook.sh] Set new version ($(getCurrentVersion)) in metadata.rb" 37 | git stash 38 | git pull origin master 39 | git stash pop 40 | git add metadata.rb 41 | git add *.md 42 | git commit -m "Bumping version to v$(getCurrentVersion)" 43 | git push origin master 44 | echo "[post-release-cookbook.sh] Release completed!" 45 | } 46 | 47 | run 48 | -------------------------------------------------------------------------------- /scripts/chef/pre-release-cookbook.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # You need to export GIT_REPO=git@github.com:YourAccount/YourProject.git before calling this script 4 | 5 | export PATH=$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH 6 | 7 | getCurrentVersion () { 8 | version=$(grep version metadata.rb | awk '{print $2}' | tr -d \'\") 9 | echo ${version} 10 | } 11 | 12 | run() { 13 | 14 | gem_installer () { 15 | local gem=$1 16 | 17 | gem list --no-installed ${gem} &>> /dev/null 18 | if [ $? == 0 ] 19 | then 20 | gem_user_install () { gem install --no-rdoc --no-ri --user-install $*; } 21 | gem_user_install ${gem} 22 | fi 23 | } 24 | # Install github_changelog_generator gem 25 | PKG_CONFIG_PATH=/opt/chefdk/embedded/lib/pkgconfig gem_installer nokogiri 26 | gem_installer github_changelog_generator 27 | 28 | export VERSION=$(getCurrentVersion) 29 | local V_VERSION=v${VERSION} 30 | 31 | export GIT_PREFIX=git@github.com 32 | export GIT_ACCOUNT_NAME=`echo ${GIT_REPO%????} | cut -d "/" -f 4` 33 | 34 | # If ARTIFACT_ID is not set, extract it from GIT_REPO 35 | # Right now it only supports HTTP Git urls 36 | if [ -z "$ARTIFACT_ID" ]; then 37 | export ARTIFACT_ID=`echo ${GIT_REPO%????} | cut -d "/" -f 5` 38 | echo "[pre-release-cookbook.sh] Setting ARTIFACT_ID=$ARTIFACT_ID" 39 | else 40 | echo "[pre-release-cookbook.sh] ARTIFACT_ID=$ARTIFACT_ID" 41 | fi 42 | 43 | if [ -z "$GIT_PROJECT_NAME" ]; then 44 | export GIT_PROJECT_NAME=$ARTIFACT_ID 45 | echo "[pre-release-cookbook.sh] Setting GIT_PROJECT_NAME=$ARTIFACT_ID" 46 | else 47 | echo "[pre-release-cookbook.sh] GIT_PROJECT_NAME=$ARTIFACT_ID" 48 | fi 49 | 50 | echo "[pre-release-cookbook.sh] Setting git remote to $GIT_PREFIX:$GIT_ACCOUNT_NAME/$GIT_PROJECT_NAME.git" 51 | git remote set-url origin $GIT_PREFIX:$GIT_ACCOUNT_NAME/$GIT_PROJECT_NAME.git 52 | 53 | echo "[pre-release-cookbook.sh] Check if there's an old tag to remove" 54 | git tag -d "${V_VERSION}" 55 | [[ $? == 0 ]] && echo "Forced removal of local tag ${V_VERSION}" 56 | 57 | echo "[pre-release-cookbook.sh] Tagging to ${VERSION}" 58 | git tag -a "${V_VERSION}" -m "releasing ${V_VERSION}" 59 | } 60 | 61 | run 62 | -------------------------------------------------------------------------------- /scripts/chef/s3-upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Uploads a file to an S3 location 4 | # It also ensures that aws commandline is installed 5 | 6 | # Example: 7 | # 8 | # BOX_LOCATION="~/.vagrant.d/data/packer-build/*.box" 9 | # S3_FOLDER_URL="https://s3.amazon.com/..." 10 | # curl -L https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/scripts/chef/s3-upload.sh --no-sessionid | bash -s -- $BOX_LOCATION $S3_FOLDER_URL 11 | 12 | if [ "$#" -ne 2 ]; then 13 | echo "Usage: s3-upload.sh " 14 | exit 1 15 | fi 16 | 17 | curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "/tmp/awscli-bundle.zip" 18 | unzip /tmp/awscli-bundle.zip -d /tmp 19 | /tmp/awscli-bundle/install -i /tmp/aws 20 | 21 | /tmp/aws/bin/aws s3 cp $1 $2 22 | -------------------------------------------------------------------------------- /scripts/chef/test-cookbook.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | runTests () { 4 | echo "[test-cookbook.sh] Running Chef, Foodcritic and ERB syntax check tests" 5 | 6 | local __rbenv_version_stash 7 | check_ruby () { 8 | # Nasty hack - I can't get kitchen working with 2.3.1 9 | # Where is ruby version defined 10 | local __version_origin=$(rbenv version-origin) 11 | [[ -z "${__version_origin}" ]] && echo 'rbenv broken' && exit 1 12 | if [ ${__version_origin} == "$(rbenv root)/version" ] 13 | then 14 | # Global Ruby Version 15 | __rbenv_version_stash='global' 16 | else 17 | # Local Ruby Version 18 | __rbenv_version_stash=$(rbenv version-name) 19 | fi 20 | 21 | # Here it is: forcing 2.2.0 22 | rbenv local 2.2.0 23 | export PATH=$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH 24 | } 25 | 26 | # Put ruby back to its original state 27 | reset_ruby () { 28 | if [ ${__rbenv_version_stash} == 'global' ] 29 | then 30 | rbenv global 31 | else 32 | rbenv local ${__rbenv_version_stash} 33 | fi 34 | } 35 | 36 | gem_installer () { 37 | local gem=$1 38 | 39 | gem list --no-installed ${gem} &>> /dev/null 40 | if [ $? == 0 ] 41 | then 42 | gem_user_install () { gem install --no-rdoc --no-ri --user-install $*; } 43 | gem_user_install ${gem} 44 | fi 45 | } 46 | 47 | check_ruby 48 | 49 | local gem 50 | for gem in foodcritic rails-erb-check jsonlint rubocop yaml-lint chef 51 | do 52 | gem_installer ${gem} 53 | done 54 | 55 | find . -not -path '*/\.*' -name "*.erb" -exec rails-erb-check {} \; 56 | find . -not -path '*/\.*' -name "*.json" -exec jsonlint {} \; 57 | find . -not -path '*/\.*' -name "*.rb" -exec ruby -c {} \; 58 | 59 | find . -not -path '*/\.*' -name "*.yml" -not -path "./.kitchen.yml" -exec yaml-lint {} \; 60 | knife cookbook test cookbook -o ./ -a 61 | foodcritic -f any . 62 | # Next one should use warning as fail-level, printing only the progress review 63 | rubocop --fail-level warn | sed -n 2p 64 | 65 | reset_ruby 66 | } 67 | 68 | runTests 69 | -------------------------------------------------------------------------------- /scripts/provisioning-libs.rb: -------------------------------------------------------------------------------- 1 | require 'json/merge_patch' 2 | require 'json' 3 | require 'yaml' 4 | 5 | def downloadFile(downloadCmd, url, destination) 6 | `#{downloadCmd} #{url} > #{destination}` 7 | if File.zero?(destination) 8 | abort("Error downloading #{url} into #{destination}! File has 0 bytes; aborting") 9 | else 10 | print "Downloaded #{url} into #{destination}\n" 11 | end 12 | end 13 | 14 | def getEnvParams() 15 | params = {} 16 | params['downloadCmd'] = ENV['DOWNLOAD_CMD'] || "curl --silent" 17 | params['workDir'] = ENV['WORK_DIR'] || "./.vagrant" 18 | params['packerBin'] = ENV['PACKER_BIN'] || 'packer' 19 | params['packerOpts'] = ENV['PACKER_OPTS'] || '' 20 | 21 | params['boxUrl'] = ENV['BOX_URL'] || "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.1_chef-provisionerless.box" 22 | params['boxName'] = ENV['BOX_NAME'] || "opscode-centos-7.1" 23 | 24 | params['cookbooksUrl'] = ENV['COOKBOOKS_URL'] || "https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/devops/chef-alfresco/0.6.13/chef-alfresco-0.6.13.tar.gz" 25 | params['dataBagsUrl'] = ENV['DATABAGS_URL'] || '' 26 | 27 | params['stackTemplateUrl'] = ENV['STACK_TEMPLATE_URL'] || "file://#{ENV['PWD']}/stack-templates/community-allinone.json" 28 | 29 | # The following are only used by Chef remote runs 30 | params['chefNodeName'] = ENV['CHEF_NODE_NAME'] 31 | params['chefInstanceTemplate'] = ENV['CHEF_INSTANCE_TEMPLATE'] 32 | params['chefLocalYamlVarsUrl'] = ENV['CHEF_LOCAL_YAML_VARS_URL'] 33 | params['chefLocalJsonVars'] = ENV['CHEF_LOCAL_JSON_VARS'] 34 | 35 | params['chefLogLevel'] = ENV['CHEF_LOG_LEVEL'] || "info" 36 | params['chefLogFile'] = ENV['CHEF_LOG_FILE'] || "/var/log/chef-client.log" 37 | 38 | # For debugging purposes 39 | # print "Returning #{params.length} Environment params\n" 40 | return params 41 | end 42 | 43 | def initWorkDir(workDir) 44 | `mkdir -p #{workDir}` 45 | `mkdir -p #{workDir}/alf_data` 46 | `chmod 777 #{workDir}/alf_data` 47 | print "Created #{workDir} #{workDir}/alf_data folders\n" 48 | end 49 | 50 | def getStackTemplateNodes(downloadCmd, workDir, stackTemplateUrl) 51 | # Download nodes URL 52 | downloadFile(downloadCmd, stackTemplateUrl, "#{workDir}/nodes.json") 53 | return JSON.parse(File.read("#{workDir}/nodes.json")) 54 | end 55 | 56 | def yamlToJson(yaml) 57 | data = YAML::load(yaml) 58 | return JSON.dump(data) 59 | end 60 | 61 | # Used for debugging purposes 62 | def printVars(params) 63 | print "#START - Printing out Vagrant environment variables:\n" 64 | params.each do |paramName,paramValue| 65 | print "#{paramName}: '"+paramValue+"'\n" 66 | end 67 | print "#END - Printing out Vagrant environment variables:\n" 68 | end 69 | 70 | def downloadArtifact(workDir, downloadCmd, url, artifactName) 71 | # Download and uncompress Chef artifacts (in a Berkshelf package format) 72 | if url and url.length != 0 73 | downloadFile(downloadCmd, url, "#{workDir}/#{artifactName}.tar.gz") 74 | `rm -rf #{workDir}/#{artifactName}; tar xzf #{workDir}/#{artifactName}.tar.gz -C #{workDir}` 75 | print "Unpacked #{workDir}/#{artifactName}.tar.gz into #{workDir}\n" 76 | end 77 | end 78 | 79 | def addNexusCredentials(attributesJson) 80 | ret = attributesJson 81 | if ENV['NEXUS_USERNAME'] and ENV['NEXUS_PASSWORD'] 82 | ret['artifact-deployer'] = {} 83 | ret['artifact-deployer']['maven'] = {} 84 | ret['artifact-deployer']['maven']['repositories'] = {} 85 | ret['artifact-deployer']['maven']['repositories']['private'] = {} 86 | ret['artifact-deployer']['maven']['repositories']['private']['url'] = "https://artifacts.alfresco.com/nexus/content/groups/private" 87 | ret['artifact-deployer']['maven']['repositories']['private']['username'] = ENV['NEXUS_USERNAME'] 88 | ret['artifact-deployer']['maven']['repositories']['private']['password'] = ENV['NEXUS_PASSWORD'] 89 | end 90 | return ret 91 | end 92 | 93 | def downloadNodeDefinition(workDir, downloadCmd, chefNodeName, instanceTemplate, localYamlVarsUrl, localJsonVars) 94 | print "Processing node '#{chefNodeName}'\n" 95 | downloadFile(downloadCmd, instanceTemplate, "#{workDir}/attributes-#{chefNodeName}.json.original") 96 | 97 | # If a Yaml file Url is specified, override Json definition 98 | if localYamlVarsUrl 99 | downloadFile(downloadCmd, localYamlVarsUrl, "#{workDir}/local-yaml-vars-#{chefNodeName}.yml") 100 | localJsonVars = yamlToJson(File.read("#{workDir}/local-yaml-vars-#{chefNodeName}.yml")) 101 | else 102 | localJsonVars = localJsonVars.to_json 103 | end 104 | 105 | # If localVars are defined, overlay the instance template JSON 106 | if localJsonVars 107 | # Debugging purposes 108 | # print "Printing out local JSON Variables:\n" 109 | # print localJsonVars + "\n" 110 | 111 | mergedAttributes = JSON.parse(JSON.merge(File.read("#{workDir}/attributes-#{chefNodeName}.json.original"), localJsonVars)) 112 | end 113 | 114 | mergedAttributes = addNexusCredentials(mergedAttributes) 115 | 116 | attributeFile = File.open("#{workDir}/attributes-#{chefNodeName}.json", 'w') 117 | attributeFile.write(mergedAttributes.to_json) 118 | attributeFile.close() 119 | 120 | print "Merged #{workDir}/attributes-#{chefNodeName}.json.original and #{workDir}/localVars.json into #{workDir}/attributes-#{chefNodeName}.json\n" 121 | end 122 | 123 | def mergePackerElementWithNodeAttributes(workDir, chefNodeName, provisionerName, provisioner) 124 | provisionerJson = JSON.parse(provisioner) 125 | nodeUrl = "#{workDir}/attributes-#{chefNodeName}.json" 126 | nodeUrlContent = File.read("#{workDir}/attributes-#{chefNodeName}.json.original") 127 | provisionerJson['json'] = JSON.parse(nodeUrlContent) 128 | provisionerJson['json'] = addNexusCredentials(provisionerJson['json']) 129 | return provisionerJson.to_json 130 | end 131 | 132 | # packerElement can be 'provisioners' or 'builders'; it's used to parse JSON input structure 133 | # packerElementType can be 'provisioner' or 'builder'; it's used to name files 134 | def parsePackerElements(downloadCmd, workDir, chefNode, chefNodeName, packerElementType, packerElement) 135 | urls = chefNode['images'][packerElement] 136 | ret = "[" 137 | urls.each do |elementName,url| 138 | packerFileName = "#{workDir}/#{elementName}-#{packerElementType}.json" 139 | downloadFile(downloadCmd, url, packerFileName) 140 | element = File.read(packerFileName) 141 | 142 | # Inject Chef attributes JSON into the chef-solo provisioner 143 | if elementName == 'chef-alfresco' 144 | element = mergePackerElementWithNodeAttributes(workDir, chefNodeName, elementName, element) 145 | end 146 | ret += element + "," 147 | end 148 | ret = ret[0..-2] 149 | ret += "]" 150 | return ret 151 | end 152 | 153 | def getPackerDefinitions(downloadCmd, workDir, nodes) 154 | packerDefinitions = {} 155 | nodes.each do |chefNodeName,chefNode| 156 | # Compose Packer JSON 157 | provisioners = parsePackerElements(downloadCmd, workDir, chefNode, chefNodeName, 'provisioner', 'provisioners') 158 | builders = parsePackerElements(downloadCmd, workDir, chefNode, chefNodeName, 'builder', 'builders') 159 | postprocessors = parsePackerElements(downloadCmd, workDir, chefNode, chefNodeName, 'postprocessor', 'postprocessors') 160 | 161 | # For debugging purposes 162 | # print "Packer Builders: #{builders}\n" 163 | # print "Packer Provisioners: #{provisioners}\n" 164 | 165 | variables = chefNode['images']['variables'].to_json 166 | packerDefinitions[chefNodeName] = "{\"variables\":#{variables},\"builders\":#{builders},\"provisioners\":#{provisioners},\"post-processors\":#{postprocessors}}" 167 | end 168 | return packerDefinitions 169 | end 170 | 171 | def getNodeAttributes(workDir, chefNodeName) 172 | boxAttributesContent = File.read("#{workDir}/attributes-#{chefNodeName}.json") 173 | return JSON.parse(boxAttributesContent) 174 | end 175 | 176 | def runPackerDefinitions(packerDefs, workDir, packerBin, packerOpts, packerLogFile) 177 | # Summarise Packer suites and ask for confirmation before running it 178 | print "Running the following Packer templates:\n" 179 | packerDefs.each do |packerDefName,packerDef| 180 | print "- #{packerDefName}-packer.json\n" 181 | end 182 | print "Check #{packerLogFile} for logs.\n" 183 | 184 | packerDefs.each do |packerDefName,packerDef| 185 | packerFile = File.open("#{workDir}/#{packerDefName}-packer.json", 'w') 186 | packerFile.write(packerDef) 187 | packerFile.close() 188 | 189 | print "Executing Packer template '#{packerDefName}-packer.json' (~ 60 minutes run)\n" 190 | if '-debug' == packerOpts 191 | `cd #{workDir}; #{packerBin} build #{packerOpts} #{packerDefName}-packer.json` 192 | else 193 | `cd #{workDir}; #{packerBin} build #{packerOpts} #{packerDefName}-packer.json >> #{packerLogFile}` 194 | end 195 | end 196 | end 197 | 198 | def downloadChefItems(nodes, workDir, downloadCmd, cookbooksUrl, dataBagsUrl) 199 | downloadArtifact(workDir, downloadCmd, cookbooksUrl, "cookbooks") 200 | downloadArtifact(workDir, downloadCmd, dataBagsUrl, "databags") 201 | 202 | # Download node URL 203 | nodes.each do |chefNodeName,chefNode| 204 | downloadNodeDefinition(workDir, downloadCmd, chefNodeName, chefNode['instance-template']['url'], chefNode['instance-template']['overlayYamlUrl'], chefNode['instance-template']['overlay']) 205 | end 206 | end 207 | 208 | def installChef() 209 | `curl --silent https://www.opscode.com/chef/install.sh | bash` 210 | end 211 | 212 | def runChef(workDir, chefLogLevel, chefLogFile, chefAttributePath) 213 | `cd #{workDir} ; chef-client --log_level #{chefLogLevel} --logfile #{chefLogFile} -z -j #{chefAttributePath}` 214 | end 215 | -------------------------------------------------------------------------------- /stacks/community-allinone/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Testing Chef provisioning, before creating an immutable image 2 | # 3 | # -*- mode: ruby -*- 4 | # vi: set ft=ruby : 5 | # 6 | cookbooks_url = "https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/devops/chef-alfresco/0.6.28/chef-alfresco-0.6.28.tar.gz" 7 | 8 | Vagrant.configure("2") do |config| 9 | config.packer_build.cookbooks_url = "#{cookbooks_url}" 10 | config.packer_build.instance_templates = ["../../instance-templates/community-allinone.json"] 11 | config.packer_build.ks_template = "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/ks/ks-centos.cfg" 12 | 13 | 14 | 15 | # Source Image configuration 16 | config.vm.box = "centos-7.2" 17 | config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box" 18 | 19 | 20 | config.vm.provision "shell", 21 | inline: "cd /tmp ; curl -L #{cookbooks_url} > cookbooks.tar.gz ; mkdir vagrant-chef ; rm -rf vagrant-chef/cookbooks ; tar xvzf cookbooks.tar.gz -C vagrant-chef" 22 | 23 | # Alfresco provisioning configurations 24 | instance_template = JSON.parse(IO.read(File.expand_path("../../instance-templates/community-allinone.json", "#{__FILE__}/.."))) 25 | 26 | # Making the run lighter 27 | instance_template['alfresco']['components'] = ["haproxy","nginx","tomcat","repo","solr","share","mysql"] 28 | instance_template['alfresco']['start_service'] = true 29 | instance_template['nginx']['disable_nginx_init'] = false 30 | instance_template['run_list'] = ["alfresco::default","alfresco::redeploy"] 31 | 32 | # Set local configurations 33 | config.vm.hostname = instance_template['name'] 34 | config.vm.network :private_network, ip: instance_template['_local']['ip'] 35 | config.vm.provider "virtualbox" do |v| 36 | v.memory = instance_template['_local']['ram'] 37 | v.cpus = instance_template['_local']['cpus'] 38 | end 39 | 40 | config.vm.provision "chef_solo" do |chef| 41 | chef.json = instance_template 42 | instance_template['run_list'].each do |recipe| 43 | chef.add_recipe recipe 44 | end 45 | end 46 | 47 | end 48 | -------------------------------------------------------------------------------- /stacks/enterprise-clustered/Vagrantfile: -------------------------------------------------------------------------------- 1 | # Testing Chef provisioning, before creating an immutable image 2 | # To use it: 3 | # VAGRANT_VAGRANTFILE=Vagrantfile.pre vagrant up 4 | # 5 | # -*- mode: ruby -*- 6 | # vi: set ft=ruby : 7 | # 8 | cookbooks_url = "https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/devops/chef-alfresco/0.6.20/chef-alfresco-0.6.20.tar.gz" 9 | run_list = ["alfresco::default"] 10 | 11 | Vagrant.configure("2") do |config| 12 | 13 | # Source Image configuration 14 | config.vm.box = "centos-7.2" 15 | config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box" 16 | 17 | # Create contentstore locally 18 | require 'fileutils' 19 | FileUtils::mkdir_p '../../alf_data' 20 | config.vm.synced_folder "../../alf_data", "/alf_data", :mount_options => ['dmode=777', 'fmode=777'] 21 | 22 | 23 | # Vagrant Packer Plugin configurations 24 | # config.packer_build.instance_templates = ["../../instance-templates/share.json","../../instance-templates/solr.json"] 25 | config.packer_build.ks_template = "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/ks/ks-centos.cfg" 26 | 27 | # TODO - hacky replacement of https://www.vagrantup.com/docs/provisioning/chef_solo.html#recipe_url 28 | # doesn't work due to issues with file permissions on 29 | # /tmp/vagrant-chef/cookbooks folder, may be an issue with 30 | # the chef-alfresco tar.gz in Nexus 31 | config.vm.provision "shell", 32 | inline: "cd /tmp ; curl -L #{cookbooks_url} > cookbooks.tar.gz ; mkdir vagrant-chef ; rm -rf vagrant-chef/cookbooks ; tar xvzf cookbooks.tar.gz -C vagrant-chef" 33 | 34 | # Setting up multi-machine 35 | ['share','solr'].each do |role| 36 | # Alfresco provisioning configurations 37 | config.vm.define role do |instance| 38 | instance_template = JSON.parse(IO.read(File.expand_path("../../instance-templates/#{role}.json", "#{__FILE__}/.."))) 39 | 40 | if role == "share" 41 | instance_template['alfresco']['properties']['dir.contentstore'] = "/vagrant/alf_data" 42 | instance_template['alfresco']['properties']['solr.host'] = "192.168.33.52" 43 | instance_template['alfresco']['properties']['solr.port'] = "8090" 44 | elsif role == "solr" 45 | instance_template['alfresco']['properties']['dir.contentstore'] = "/vagrant/alf_data" 46 | instance_template['alfresco']['properties']['db.host'] = "192.168.33.51" 47 | end 48 | 49 | # Set local configurations 50 | instance.vm.hostname = instance_template['name'] 51 | instance.vm.network :private_network, ip: instance_template['_local']['ip'] 52 | instance.vm.provider "virtualbox" do |v| 53 | v.memory = instance_template['_local']['ram'] 54 | v.cpus = instance_template['_local']['cpus'] 55 | end 56 | 57 | instance.vm.provision "chef_solo" do |chef| 58 | chef.json = instance_template 59 | run_list.each do |recipe| 60 | chef.add_recipe recipe 61 | end 62 | end 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /test/Vagrantfile.post: -------------------------------------------------------------------------------- 1 | # Testing Alfresco Community Vagrant .box file 2 | # 3 | # -*- mode: ruby -*- 4 | # vi: set ft=ruby : 5 | # 6 | 7 | # For now: 8 | # vagrant box add ../.vagrant/packer/alfresco-community-5.1.c-ea-1450080171.box --name alfresco-community-5.1.c-ea-1450080171 9 | # TODO - WIP 10 | # image_url_prefix = "https://s3.amazonaws.com/alfresco-images/vagrantboxes" 11 | 12 | image_name="alfresco-community" 13 | image_timestamp="1450080171" 14 | image_version="5.1.c-ea" 15 | image_version = "#{image_version}-#{image_timestamp}" if image_timestamp 16 | image_name_and_version = "#{image_name}-#{image_version}" 17 | 18 | instance_ip = "192.168.0.42" 19 | 20 | Vagrant.configure("2") do |config| 21 | config.vm.box = image_name_and_version 22 | # TODO - WIP 23 | # config.vm.url = "#{image_url_prefix}/#{image_name_and_version}.box" 24 | config.vm.hostname = image_name 25 | config.vm.network :private_network, ip: instance_ip 26 | end 27 | -------------------------------------------------------------------------------- /test/docker/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # # vi: set ft=ruby : 3 | 4 | Vagrant.require_version ">= 1.6.0" 5 | 6 | Vagrant.configure("2") do |config| 7 | 8 | config.vm.box = "bento/centos-7.1" 9 | config.vm.box_url = "https://atlas.hashicorp.com/bento/boxes/centos-7.1" 10 | config.vm.synced_folder "../", "/spk/" 11 | config.vm.network :private_network, ip: "172.17.8.23" 12 | 13 | config.vm.define "image-builder" do 14 | config.vm.provision "shell", path: "install-packer.sh" 15 | config.vm.provision "shell", path: "install-vagrant.sh" 16 | config.vm.provision "shell", path: "install-docker.sh" 17 | config.vm.provision "shell", path: "pull-docker-images.sh" 18 | config.vm.provision "shell", path: "check-docker-daemon.sh" 19 | config.vm.provision "shell", path: "build-docker-images.sh" 20 | config.vm.provision "shell", path: "run-docker-stack.sh" 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /test/docker/build-docker-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | echo "Run alfresco-spk withing CentOS..." 5 | cd /spk 6 | export PACKER_BIN=/opt/packer/packer 7 | vagrant plugin install json-merge_patch 8 | export STACK_TEMPLATE_URL=file:///spk/stack-templates/community-allinone-docker.json 9 | vagrant up build-images 10 | -------------------------------------------------------------------------------- /test/docker/check-docker-daemon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Check if Docker is running 4 | ps auxwf|grep "docker daemon"|grep -v grep 5 | if [ $? -eq 1 ]; then 6 | sudo service docker start 7 | fi 8 | -------------------------------------------------------------------------------- /test/docker/install-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Installing Docker 4 | if [ ! -f /usr/bin/docker ]; then 5 | echo "Installing and starting Docker..." 6 | curl -sSL https://get.docker.com/ | sh 7 | service docker start 8 | fi 9 | 10 | -------------------------------------------------------------------------------- /test/docker/install-packer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -f /usr/bin/unzip ]; then 4 | echo "Downloadin upzip..." 5 | yum -y install unzip 6 | fi 7 | 8 | #Installing Packer 9 | if [ ! -f /opt/packer/packer ]; then 10 | echo "Downloading Packer (126MB)..." 11 | wget -q https://dl.bintray.com/mitchellh/packer/packer_0.8.6_linux_amd64.zip 12 | mkdir -p /opt/packer; unzip -o packer_0.8.6_linux_amd64.zip -d /opt/packer 13 | fi 14 | -------------------------------------------------------------------------------- /test/docker/install-vagrant.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -f /usr/bin/vagrant ]; then 4 | echo "Installing Vagrant..." 5 | wget -q https://releases.hashicorp.com/vagrant/1.7.4/vagrant_1.7.4_x86_64.rpm 6 | rpm -ihv vagrant_1.7.4_x86_64.rpm 7 | fi 8 | -------------------------------------------------------------------------------- /test/docker/pull-docker-images.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Download pre-defined Docker Images 4 | echo "Pulling Docker images..." 5 | docker pull centos 6 | docker pull orchardup/mysql:latest 7 | 8 | # Not used ATM 9 | # docker pull crosbymichael/skydns:latest 10 | # docker pull crosbymichael/skydock:latest 11 | # docker pull dockerfile/haproxy:latest 12 | -------------------------------------------------------------------------------- /test/docker/run-docker-stack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Use kubernetes, docker compose 4 | -------------------------------------------------------------------------------- /test/old-stack-templates/community-allinone-docker.json: -------------------------------------------------------------------------------- 1 | { 2 | "alfresco-allinone" : { 3 | "instance-template" : { 4 | "url" : "file:///spk/instance-templates/repo-community-container.json", 5 | "overlay" : { 6 | "alfresco" : { 7 | "install_fonts" : false 8 | }, 9 | "nginx" : { 10 | "use_nossl_config" : true 11 | } 12 | } 13 | }, 14 | "local-run" : { 15 | "memory" : "2048", 16 | "cpus" : "2" 17 | }, 18 | "images" : { 19 | "provisioners" : { 20 | "chef-alfresco" : "file:///spk/packer/chef-provisioner.json", 21 | "image-cleanup" : "file://$PWD/packer/image-cleanup-provisioner.json" 22 | }, 23 | "builders" : { 24 | "docker" : "file:///spk/packer/docker-builder.json" 25 | }, 26 | "variables" : { 27 | "data_bags_path" : ".", 28 | "chef_version" : "12.6.0", 29 | "chef_prevent_sudo" : "true", 30 | "run_list_item" : "alfresco::default" 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/old-stack-templates/community-allinone-vagrantbox.json: -------------------------------------------------------------------------------- 1 | { 2 | "alfresco-allinone" : { 3 | "instance-template" : { 4 | "url" : "file://$PWD/instance-templates/community-allinone.json", 5 | "overlay" : { 6 | "alfresco" : { 7 | "install_fonts" : false 8 | }, 9 | "nginx" : { 10 | "use_nossl_config" : true 11 | } 12 | } 13 | }, 14 | "local-run" : { 15 | "memory" : "2048", 16 | "cpus" : "2" 17 | }, 18 | "images" : { 19 | "provisioners" : { 20 | "selinux-permissive" : "file://$PWD/packer/selinux-permissive-provisioner.json", 21 | "chef-alfresco" : "file://$PWD/packer/chef-provisioner.json", 22 | "vagrant-key" : "file://$PWD/packer/vagrant-key-provisioner.json", 23 | "bento-vagrant" : "file://$PWD/packer/bento-vagrant-provisioner.json", 24 | "image-cleanup" : "file://$PWD/packer/image-cleanup-provisioner.json" 25 | }, 26 | "builders" : { 27 | "virtualbox-ovf" : "file://$PWD/packer/virtualbox-ovf-builder.json" 28 | }, 29 | "postprocessors" : { 30 | "vagrantbox" : "file://$PWD/packer/vagrantbox-postprocessor.json" 31 | }, 32 | "variables" : { 33 | "data_bags_path" : ".", 34 | "chef_version" : "12.6.0", 35 | "chef_prevent_sudo" : "true", 36 | "run_list_item" : "alfresco::default", 37 | "vagrant_output_file" : "alfresco-community-5.1.c-ea-{{timestamp}}", 38 | "iso_url" : "http://centos.mirror.transip.nl/7/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso", 39 | "iso_checksum" : "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284", 40 | "iso_checksum_type" : "sha256", 41 | "ssh_username" : "root", 42 | "ssh_password" : "vagrant", 43 | "ks_path" : "ks.cfg", 44 | "http_directory" : "../", 45 | "headless" : "false", 46 | "guest_os_type" : "RedHat_64", 47 | "output_directory": "vbox-output", 48 | "keep_ovf_file" : "true", 49 | "root_disk_size" : "70", 50 | "root_delete_on_termination" : "true", 51 | "vm_name": "alfresco-community-5.1.c-ea-{{timestamp}}" 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /test/old-stack-templates/community-allinone.json: -------------------------------------------------------------------------------- 1 | { 2 | "alfresco-allinone" : { 3 | "instance-template" : { 4 | "url" : "./instance-templates/community-allinone.json" 5 | }, 6 | "images" : { 7 | "provisioners" : { 8 | "selinux-permissive" : "./packer/provisioners/selinux-permissive.json", 9 | "chef-alfresco" : "./packer/provisioners/chef.json", 10 | "image-cleanup" : "./packer/provisioners/image-cleanup.json" 11 | }, 12 | "builders" : { 13 | "amazon-ebs" : "./packer/builders/amazon-ebs.json" 14 | }, 15 | "variables" : { 16 | "chef_version" : "12.6.0", 17 | "chef_prevent_sudo" : "false", 18 | "run_list_item" : "alfresco::default", 19 | "ami_description" : "Alfresco Community 5.1.c-EA - Allinone Server - {{timestamp}}", 20 | "ami_name" : "Alfresco Community 5.1.c-EA - Allinone Server - {{timestamp}}" 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/old-stack-templates/community-allinone.json.yamlexample: -------------------------------------------------------------------------------- 1 | { 2 | "alfresco-allinone" : { 3 | "instance-template" : { 4 | "url" : "file://$PWD/instance-templates/community-allinone.json", 5 | "overlayYamlUrl" : "file://$PWD/yaml-overlays/allinone.yml" 6 | }, 7 | "local-run" : { 8 | "memory" : "2048", 9 | "cpus" : "2" 10 | }, 11 | "images" : { 12 | "provisioners" : { 13 | "selinux-permissive" : "file://$PWD/packer/selinux-permissive-provisioner.json", 14 | "chef-alfresco" : "file://$PWD/packer/chef-provisioner.json", 15 | "image-cleanup" : "file://$PWD/packer/image-cleanup-provisioner.json" 16 | }, 17 | "builders" : { 18 | "amazon-ebs" : "file://$PWD/packer/amazon-ebs-builder.json" 19 | }, 20 | "variables" : { 21 | "data_bags_path" : ".", 22 | "chef_version" : "12.6.0", 23 | "run_list_item" : "alfresco::default", 24 | "ami_description" : "Alfresco Community 5.1.c-EA - Allinone Server - {{timestamp}}", 25 | "ami_name" : "Alfresco Community 5.1.c-EA - Allinone Server - {{timestamp}}" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/old-stack-templates/community-allinone.vagrant.rb: -------------------------------------------------------------------------------- 1 | # Testing Chef provisioning, before creating an immutable image 2 | # To use it: 3 | # VAGRANT_VAGRANTFILE=Vagrantfile.pre vagrant up 4 | # 5 | # -*- mode: ruby -*- 6 | # vi: set ft=ruby : 7 | # 8 | 9 | instance_template_path = "../instance-templates/community-allinone.json" 10 | cookbooks_url = "https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/devops/chef-alfresco/0.6.20/chef-alfresco-0.6.20.tar.gz" 11 | run_list = ["alfresco::default"] 12 | 13 | Vagrant.configure("2") do |config| 14 | 15 | # Vagrant Packer Plugin configurations 16 | config.packer_build.instance_templates = ["./spk/build-vagrantbox.json"] 17 | config.packer_build.ks_template = "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/ks/ks-centos.cfg" 18 | 19 | # Source Image configuration 20 | config.vm.box = "centos-7.2" 21 | config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box" 22 | 23 | # TODO - hacky replacement of https://www.vagrantup.com/docs/provisioning/chef_solo.html#recipe_url 24 | # doesn't work due to issues with file permissions on 25 | # /tmp/vagrant-chef/cookbooks folder, may be an issue with 26 | # the chef-alfresco tar.gz in Nexus 27 | config.vm.provision "shell", 28 | inline: "cd /tmp ; curl -L #{cookbooks_url} > cookbooks.tar.gz ; mkdir vagrant-chef ; rm -rf vagrant-chef/cookbooks ; tar xvzf cookbooks.tar.gz -C vagrant-chef" 29 | 30 | # Alfresco provisioning configurations 31 | instance_template = JSON.parse(IO.read(File.expand_path(instance_template_path, "#{__FILE__}/.."))) 32 | 33 | # Set local configurations 34 | config.vm.hostname = instance_template['name'] 35 | config.vm.network :private_network, ip: instance_template['_local']['ip'] 36 | config.vm.provider "virtualbox" do |v| 37 | v.memory = instance_template['_local']['ram'] 38 | v.cpus = instance_template['_local']['cpus'] 39 | end 40 | 41 | config.vm.provision "chef_solo" do |chef| 42 | chef.json = instance_template 43 | run_list.each do |recipe| 44 | chef.add_recipe recipe 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /test/old-stack-templates/enterprise-clustered.json: -------------------------------------------------------------------------------- 1 | { 2 | "alfresco-share1" : { 3 | "instance-template" : { 4 | "url" : "file://$PWD/instance-templates/share.json", 5 | "overlay" : { 6 | "alfresco" : { 7 | "components" : ["haproxy","nginx","tomcat","transform","repo","share","aos","mysql"], 8 | "ssl_enabled" : false, 9 | "skip_certificate_creation" : true, 10 | "public_protocol" : "http", 11 | "public_portssl" : "80", 12 | "install_fonts" : false, 13 | "properties" : { 14 | "dir.contentstore" : "/vagrant/.vagrant/alf_data", 15 | "solr.host" : "192.168.33.21", 16 | "solr.port" : "8090" 17 | } 18 | }, 19 | "nginx" : { 20 | "use_nossl_config": true 21 | }, 22 | "haproxy" : { 23 | "enable_ssl_header" : false 24 | } 25 | } 26 | }, 27 | "local-run" : { 28 | "memory" : "800", 29 | "cpus" : "1", 30 | "ip" : "192.168.33.11" 31 | }, 32 | "images" : { 33 | "provisioners" : { 34 | "chef-alfresco" : "file://$PWD/packer/chef-provisioner.json", 35 | "image-cleanup" : "file://$PWD/packer/image-cleanup-provisioner.json" 36 | }, 37 | "builders" : { 38 | "amazon-ebs" : "file://$PWD/packer/amazon-ebs-builder.json" 39 | }, 40 | "variables" : { 41 | "data_bags_path" : ".", 42 | "chef_version" : "12.6.0", 43 | "chef_prevent_sudo" : "false", 44 | "run_list_item" : "alfresco::default", 45 | "ami_description" : "Alfresco One 5.0.2 - Share Server - {{timestamp}}", 46 | "ami_name" : "Alfresco One 5.0.2 - Share Server - {{timestamp}}" 47 | } 48 | } 49 | }, 50 | "alfresco-share2" : { 51 | "instance-template" : { 52 | "url" : "file://$PWD/instance-templates/share.json", 53 | "overlay" : { 54 | "alfresco" : { 55 | "components" : ["haproxy","nginx","tomcat","transform","repo","share","aos"], 56 | "ssl_enabled" : false, 57 | "skip_certificate_creation" : true, 58 | "public_protocol" : "http", 59 | "public_portssl" : "80", 60 | "install_fonts" : false, 61 | "properties" : { 62 | "dir.contentstore" : "/vagrant/.vagrant/alf_data", 63 | "db.host" : "192.168.33.11", 64 | "solr.host" : "192.168.33.22", 65 | "solr.port" : "8090" 66 | } 67 | }, 68 | "nginx" : { 69 | "use_nossl_config": true 70 | }, 71 | "haproxy" : { 72 | "enable_ssl_header" : false 73 | } 74 | } 75 | }, 76 | "local-run" : { 77 | "memory" : "800", 78 | "cpus" : "1", 79 | "ip" : "192.168.33.11" 80 | } 81 | }, 82 | "alfresco-solr1" : { 83 | "instance-template" : { 84 | "url" : "file://$PWD/instance-templates/solr.json", 85 | "overlay" : { 86 | "alfresco" : { 87 | "ssl_enabled" : false, 88 | "skip_certificate_creation" : true, 89 | "install_fonts" : false, 90 | "properties" : { 91 | "dir.contentstore" : "/vagrant/.vagrant/alf_data", 92 | "db.host" : "192.168.33.11" 93 | } 94 | } 95 | } 96 | }, 97 | "local-run" : { 98 | "memory" : "800", 99 | "cpus" : "1", 100 | "ip" : "192.168.33.21" 101 | }, 102 | "images" : { 103 | "provisioners" : { 104 | "chef-alfresco" : "file://$PWD/packer/provisioners/chef.json", 105 | "image-cleanup" : "file://$PWD/packer/provisioners/image-cleanup.json" 106 | }, 107 | "builders" : { 108 | "amazon-ebs" : "file://$PWD/packer/builders/amazon-ebs.json" 109 | }, 110 | "variables" : { 111 | "data_bags_path" : ".", 112 | "chef_version" : "12.6.0", 113 | "chef_prevent_sudo" : "false", 114 | "run_list_item" : "alfresco::default", 115 | "ami_description" : "Alfresco One 5.0.2 - Index Server - {{timestamp}}", 116 | "ami_name" : "Alfresco One 5.0.2 - Index Server - {{timestamp}}" 117 | } 118 | } 119 | }, 120 | "alfresco-solr2" : { 121 | "instance-template" : { 122 | "url" : "file://$PWD/instance-templates/solr.json", 123 | "overlay" : { 124 | "alfresco" : { 125 | "ssl_enabled" : false, 126 | "skip_certificate_creation" : true, 127 | "install_fonts" : false, 128 | "properties" : { 129 | "dir.contentstore" : "/vagrant/.vagrant/alf_data", 130 | "db.host" : "192.168.33.11" 131 | } 132 | } 133 | } 134 | }, 135 | "local-run" : { 136 | "memory" : "800", 137 | "cpus" : "1", 138 | "ip" : "192.168.33.22" 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /test/old-stack-templates/enterprise-clustered.vagrant.rb: -------------------------------------------------------------------------------- 1 | # Testing Chef provisioning, before creating an immutable image 2 | # To use it: 3 | # VAGRANT_VAGRANTFILE=Vagrantfile.pre vagrant up 4 | # 5 | # -*- mode: ruby -*- 6 | # vi: set ft=ruby : 7 | # 8 | 9 | cookbooks_url = "https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/devops/chef-alfresco/0.6.20/chef-alfresco-0.6.20.tar.gz" 10 | run_list = ["alfresco::default"] 11 | 12 | Vagrant.configure("2") do |config| 13 | 14 | # Vagrant Packer Plugin configurations 15 | config.packer_build.instance_templates = ["./spk/build-vagrantbox.json"] 16 | config.packer_build.ks_template = "https://raw.githubusercontent.com/Alfresco/alfresco-spk/master/ks/ks-centos.cfg" 17 | 18 | # Source Image configuration 19 | config.vm.box = "centos-7.2" 20 | config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_centos-7.2_chef-provisionerless.box" 21 | 22 | # TODO - hacky replacement of https://www.vagrantup.com/docs/provisioning/chef_solo.html#recipe_url 23 | # doesn't work due to issues with file permissions on 24 | # /tmp/vagrant-chef/cookbooks folder, may be an issue with 25 | # the chef-alfresco tar.gz in Nexus 26 | config.vm.provision "shell", 27 | inline: "cd /tmp ; curl -L #{cookbooks_url} > cookbooks.tar.gz ; mkdir vagrant-chef ; rm -rf vagrant-chef/cookbooks ; tar xvzf cookbooks.tar.gz -C vagrant-chef" 28 | 29 | # Setting up multi-machine 30 | ['share','solr'].each do |role| 31 | # Alfresco provisioning configurations 32 | config.vm.define role do |instance| 33 | instance_template = JSON.parse(IO.read(File.expand_path("../instance-templates/#{role}.json", "#{__FILE__}/.."))) 34 | 35 | # Set local configurations 36 | config.vm.hostname = instance_template['name'] 37 | config.vm.network :private_network, ip: instance_template['_local']['ip'] 38 | config.vm.provider "virtualbox" do |v| 39 | v.memory = instance_template['_local']['ram'] 40 | v.cpus = instance_template['_local']['cpus'] 41 | end 42 | 43 | config.vm.provision "chef_solo" do |chef| 44 | chef.json = instance_template 45 | run_list.each do |recipe| 46 | chef.add_recipe recipe 47 | end 48 | end 49 | end 50 | end 51 | end 52 | --------------------------------------------------------------------------------