├── LICENSE ├── README.md ├── create_trove_image.sh ├── elements ├── centos-mongodb-guest-image │ ├── element-deps │ ├── install.d │ │ ├── 10-mongodb │ │ └── 25-trove-mongo-dep │ ├── mongodb26.repo │ └── post-install.d │ │ └── 30-register-mongodb-service ├── centos-mysql-guest-image │ ├── element-deps │ ├── install.d │ │ ├── 30-mysql │ │ └── 40-xtrabackup │ ├── mariadb10.repo │ └── post-install.d │ │ └── 30-register-mysql-service ├── centos-postgresql-guest-image │ ├── element-deps │ ├── install.d │ │ └── 10-postgresql │ └── post-install.d │ │ ├── 20-init-postgresql │ │ └── 30-register-postgresql-service ├── centos-trove-guest │ └── element-deps ├── cloud-init-datasources │ └── install.d │ │ └── 05-set-cloud-init-sources ├── fedora-mongodb-guest-image │ ├── element-deps │ ├── install.d │ │ ├── 10-mongodb │ │ └── 25-trove-mongo-dep │ └── post-install.d │ │ └── 30-register-mongodb-service ├── fedora-mysql-guest-image │ ├── element-deps │ ├── install.d │ │ └── 30-mysql │ └── post-install.d │ │ └── 30-register-mysql-service ├── fedora-postgresql-guest-image │ ├── element-deps │ ├── install.d │ │ └── 10-postgresql │ └── post-install.d │ │ ├── 20-init-postgresql │ │ └── 30-register-postgresql-service ├── fedora-trove-guest │ └── element-deps ├── rhel-mongodb-guest-image │ ├── element-deps │ ├── install.d │ │ ├── 10-mongodb │ │ └── 25-trove-mongo-dep │ └── post-install.d │ │ └── 30-register-mongodb-service ├── rhel-mysql-guest-image │ ├── element-deps │ ├── install.d │ │ └── 30-mysql │ └── post-install.d │ │ └── 30-register-mysql-service ├── rhel-postgresql-guest-image │ ├── element-deps │ ├── install.d │ │ └── 10-postgresql │ └── post-install.d │ │ ├── 20-init-postgresql │ │ └── 30-register-postgresql-service ├── rhel-trove-guest │ └── element-deps ├── system-configuration │ ├── finalise.d │ │ └── 60-set-no-timer-check │ ├── id_rsa │ ├── id_rsa.pub │ ├── install.d │ │ └── 01-user │ └── post-install.d │ │ ├── 10-ntp │ │ ├── 20-ssh │ │ ├── 62-trove-guest-sudoers │ │ ├── 90-yum-update │ │ └── 99-fpaste └── trove-guest │ ├── install.d │ └── 15-install-trove │ ├── openstack-trove-guestagent.service │ └── post-install.d │ └── 30-register-guest-service └── load_trove_image.sh /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Image elements for building Trove guest images 2 | ============================================== 3 | 4 | Building prerequisites 5 | ---------------------- 6 | 7 | Each image for datastore should include next mandatory elements: 8 | 9 | ${DISTRO}-${DATASTORE}-guest-image (for example rhel-mysql-guest-image, rhel-mongodb-guest-image, etc.) 10 | 11 | Building images 12 | --------------- 13 | 14 | Without the script 15 | ------------------ 16 | 17 | To build an image without the script, make sure you have diskimage-builder installed (yum install -y diskimage-builder) 18 | and run the following commands: 19 | 20 | # RHEL related required env 21 | export REG_METHOD=portal 22 | export REG_USER= 23 | export REG_PASSWORD= 24 | export REG_MACHINE_NAME=trove 25 | export REG_POOL_ID= 26 | 27 | # DIB related required env 28 | export DISTRO= 29 | export DATASTORE= 30 | export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive" 31 | disk-image-create -a amd64 \ 32 | -o ${DISTRO}-${DATASTORE}-guest-image \ 33 | -x --qemu-img-options compat=0.10 \ 34 | ${DISTRO}-${DATASTORE}-guest-image 35 | 36 | Note. Only anonymous HTTP(S) accessable Git repos are allowed. 37 | 38 | With the script 39 | --------------- 40 | 41 | Simply run 'sudo ./create-trove-image.sh -h' to see run instructions. 42 | 43 | 44 | Based on 45 | -------- 46 | 47 | https://github.com/denismakogon/trove-guest-image-elements 48 | -------------------------------------------------------------------------------- /create_trove_image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | err() { 6 | echo "${0##*/}: $@" >&2 7 | } 8 | 9 | print_usage() { 10 | echo "Usage: ${0##*/} [-d distro] [-s datastore] [-i | -u | -p | -o | -h]" 11 | echo "Options:" 12 | echo " -d | --distro: name of the system to use. Possible options are fedora, centos or rhel." 13 | echo " -s | --datastore: name of the storage backend to use. Possible options are mysql, mongodb, or postgresql." 14 | echo " -i | --local-image: path to the local image. Defaults to diskimage-builder location." 15 | echo " -u | --rh-user: subscription user for rhel." 16 | echo " -p | --rh-password: subcription password for rhel." 17 | echo " -o | --rh-pool-id: pool id to attach to in rhel." 18 | echo " -h | --help: print this usage message and exit" 19 | echo "" 20 | echo "Usage example: create_trove_image -d fedora -s mysql" 21 | } 22 | 23 | check_root() { 24 | local user=$(/usr/bin/id -u) 25 | if [ ${user} -ne 0 ]; then 26 | err "You need to be root (uid 0) to run this script." 27 | exit 1 28 | fi 29 | } 30 | 31 | parse_arguments() { 32 | while [[ $# > 0 ]]; do 33 | case "$1" in 34 | -d|--distro) 35 | export DISTRO=$2 36 | valid_distro_control 37 | shift 2 38 | ;; 39 | -s|--datastore) 40 | export DATASTORE=$2 41 | shift 2 42 | ;; 43 | -i|--local-image) 44 | # TODO(vkmc): Add option to use image in Glance 45 | export DIB_LOCAL_IMAGE=$2 46 | shift 2 47 | ;; 48 | -u|--rh-user) 49 | export REG_USER=$2 50 | shift 2 51 | ;; 52 | -p|--rh-password) 53 | export REG_PASSWORD=$2 54 | shift 2 55 | ;; 56 | -o|--rh-pool-id) 57 | export REG_POOL_ID=$2 58 | shift 2 59 | ;; 60 | -h|--help) 61 | print_usage 62 | exit 0 63 | ;; 64 | -*) 65 | err "Error: Unknown option: $1." 66 | exit 1 67 | ;; 68 | *) 69 | break 70 | ;; 71 | esac 72 | done 73 | } 74 | 75 | init_variables() { 76 | export DIB_REPO_PATH="/usr/share/diskimage-builder" 77 | export ELEMENTS_PATH="$DIB_REPO_PATH/elements:./elements" 78 | 79 | # TODO(vkmc): Make REG_METHOD configurable 80 | export REG_METHOD=portal 81 | export REG_MACHINE_NAME=trove 82 | 83 | export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive,EC2" 84 | } 85 | 86 | install_requirements() { 87 | sudo yum install -y diskimage-builder 88 | } 89 | 90 | valid_distro_control() { 91 | if [ "${DISTRO}" != "fedora" ] && [ "${DISTRO}" != "centos" ] && [ "${DISTRO}" != "rhel" ]; then 92 | err "Distro ${DISTRO} not supported. Valid options are fedora, centos or rhel." 93 | exit 1 94 | fi 95 | } 96 | 97 | required_params_control() { 98 | : ${DISTRO:?"Name of the system to use is required. Possible options are fedora, centos or rhel."} 99 | : ${DATASTORE:?"Name of the datastore to use required. Possible options are mysql, mongodb, or postgresql."} 100 | } 101 | 102 | rhel_subscription_control() { 103 | if [ "${DISTRO}" = "rhel" ]; then 104 | : ${REG_USER:?"You need to set RHEL subscription user."} 105 | : ${REG_PASSWORD:?"You need to set RHEL subscription password."} 106 | : ${REG_POOL_ID:?"You need to set RHEL pool ID."} 107 | fi 108 | } 109 | 110 | main() { 111 | check_root 112 | parse_arguments "$@" 113 | required_params_control 114 | rhel_subscription_control 115 | install_requirements 116 | init_variables 117 | disk-image-create -a amd64 -o ${DISTRO}-${DATASTORE}-guest-image -x --qemu-img-options compat=0.10 ${DISTRO}-${DATASTORE}-guest-image 118 | exit 0 119 | } 120 | 121 | main "$@" 122 | -------------------------------------------------------------------------------- /elements/centos-mongodb-guest-image/element-deps: -------------------------------------------------------------------------------- 1 | centos-trove-guest 2 | selinux-permissive 3 | -------------------------------------------------------------------------------- /elements/centos-mongodb-guest-image/install.d/10-mongodb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # CONTEXT: GUEST during CONSTRUCTION as ROOT 4 | # PURPOSE: Install controller base required packages 5 | 6 | set -e 7 | set -o xtrace 8 | 9 | # yum install -y mongodb mongodb-server 10 | 11 | dd if=/tmp/in_target.d/mongodb26.repo of=/etc/yum.repos.d/mongodb26.repo 12 | 13 | yum install -y mongodb-org mongodb-org-server 14 | 15 | # the following config changes are needed: smallfiles set to true, and bind_ip 16 | # set to default 17 | sed -i '/bind_ip/d' /etc/mongod.conf 18 | sed -i '/smallfiles/d' /etc/mongod.conf 19 | echo 'smallfiles = true' >> /etc/mongod.conf 20 | -------------------------------------------------------------------------------- /elements/centos-mongodb-guest-image/install.d/25-trove-mongo-dep: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # CONTEXT: GUEST during CONSTRUCTION as ROOT 4 | # PURPOSE: Install trove guest python dependencies - see redstack functions_qemu 5 | 6 | set -e 7 | set -o xtrace 8 | 9 | yum -y install pymongo 10 | -------------------------------------------------------------------------------- /elements/centos-mongodb-guest-image/mongodb26.repo: -------------------------------------------------------------------------------- 1 | [mongodb-org-2.6] 2 | name=MongoDB 2.6 Repository 3 | baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ 4 | gpgcheck=0 5 | enabled=1 6 | -------------------------------------------------------------------------------- /elements/centos-mongodb-guest-image/post-install.d/30-register-mongodb-service: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o xtrace 5 | 6 | # Enable and start service 7 | systemctl enable mongod.service 8 | systemctl start mongod.service 9 | -------------------------------------------------------------------------------- /elements/centos-mysql-guest-image/element-deps: -------------------------------------------------------------------------------- 1 | centos-trove-guest 2 | -------------------------------------------------------------------------------- /elements/centos-mysql-guest-image/install.d/30-mysql: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # CONTEXT: GUEST during CONSTRUCTION as ROOT 4 | # PURPOSE: Install controller base required packages 5 | 6 | set -e 7 | set -o xtrace 8 | 9 | # install mariadb 5.5 (through mariadb-galera-server) 10 | yum -y install mysql mysql-server 11 | mkdir /etc/mysql 12 | ln -s /etc/my.cnf /etc/mysql/my.cnf 13 | 14 | # install mariadb 10 15 | # dd if=/tmp/in_target.d/mariadb10.repo of=/etc/yum.repos.d/mariadb10.repo 16 | 17 | # yum -y update 18 | # yum -y install MariaDB-server MariaDB-client 19 | -------------------------------------------------------------------------------- /elements/centos-mysql-guest-image/install.d/40-xtrabackup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # CONTEXT: GUEST during CONSTRUCTION as ROOT 4 | # PURPOSE: Install controller base required packages 5 | 6 | set -e 7 | set -o xtrace 8 | 9 | yum -y install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm 10 | echo exclude=Percona-SQL* Percona-Server* Percona-XtraDB-Cluster* >> /etc/yum.conf 11 | yum -y install percona-xtrabackup 12 | -------------------------------------------------------------------------------- /elements/centos-mysql-guest-image/mariadb10.repo: -------------------------------------------------------------------------------- 1 | # MariaDB 10.0 CentOS repository list - created 2015-06-15 17:04 UTC 2 | # http://mariadb.org/mariadb/repositories/ 3 | [mariadb] 4 | name = MariaDB 5 | baseurl = http://yum.mariadb.org/10.0/centos7-amd64 6 | gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 7 | gpgcheck=0 8 | -------------------------------------------------------------------------------- /elements/centos-mysql-guest-image/post-install.d/30-register-mysql-service: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o xtrace 5 | 6 | # Enable and start service 7 | systemctl enable mariadb.service 8 | systemctl start mariadb.service 9 | # systemctl enable mysql.service 10 | # systemctl start mysql.service 11 | -------------------------------------------------------------------------------- /elements/centos-postgresql-guest-image/element-deps: -------------------------------------------------------------------------------- 1 | centos-trove-guest 2 | -------------------------------------------------------------------------------- /elements/centos-postgresql-guest-image/install.d/10-postgresql: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # CONTEXT: GUEST during CONSTRUCTION as ROOT 4 | # PURPOSE: Install controller base required packages 5 | 6 | set -e 7 | set -o xtrace 8 | 9 | yum install -y postgresql-server 10 | -------------------------------------------------------------------------------- /elements/centos-postgresql-guest-image/post-install.d/20-init-postgresql: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o xtrace 5 | 6 | su - postgres -c "/usr/bin/initdb /var/lib/pgsql/data" 7 | -------------------------------------------------------------------------------- /elements/centos-postgresql-guest-image/post-install.d/30-register-postgresql-service: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o xtrace 5 | 6 | # Enable and start service 7 | systemctl enable postgresql.service 8 | systemctl start postgresql.service 9 | -------------------------------------------------------------------------------- /elements/centos-trove-guest/element-deps: -------------------------------------------------------------------------------- 1 | base 2 | vm 3 | cloud-init-datasources 4 | selinux-permissive 5 | centos7 6 | system-configuration 7 | trove-guest 8 | -------------------------------------------------------------------------------- /elements/cloud-init-datasources/install.d/05-set-cloud-init-sources: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | set -o pipefail 5 | 6 | DIB_CLOUD_INIT_DATASOURCES=${DIB_CLOUD_INIT_DATASOURCES:-""} 7 | 8 | if [ -z "$DIB_CLOUD_INIT_DATASOURCES" ] ; then 9 | echo "DIB_CLOUD_INIT_DATASOURCES must be set to a comma-separated list " 10 | echo "of cloud-init data sources you wish to use, ie 'Ec2, NoCloud, ConfigDrive'" 11 | exit 1 12 | fi 13 | 14 | # DatasourceNone doesn't exist in Ubuntu 12.04 (Precise) 15 | # which uses cloud-init version 0.6.3 16 | if [ "$(lsb_release -cs)" = 'precise' ] ; then 17 | cat > /etc/cloud/cloud.cfg.d/91-dib-cloud-init-datasources.cfg < /etc/cloud/cloud.cfg.d/91-dib-cloud-init-datasources.cfg < /etc/default/grub 6 | grub2-mkconfig > /boot/grub2/grub.cfg 7 | -------------------------------------------------------------------------------- /elements/system-configuration/id_rsa: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEpAIBAAKCAQEA5kHgP7shMhX/Q7JsEfjs7Vm+x2/7kwvkd8RtUIAb0cIUm6QZ 3 | 8gREhjGWdO2yMOSG+wVEg88KHq8lKjQIQIYq9ii3iGDg0t/VJk8DiJfqyL4ZU8Yb 4 | CKEB1fdKXsA9qsNE/CoFTD1A7ENAXffBOnuXW8XImaeu4oVQ9K+7K4XUkaPDyHOe 5 | oSVqw+do+RXoiBhJi1x14mSzspmtTO4/xJolfNcBwM4KperIoVkmR5t8T2We9dib 6 | V25h4Xt0SxSCtd7vT0m9127hCHRsJGXcz/r2DRNArGKsI141Ua2PwD7IhJG0jVcx 7 | yOadltS+2TLUjjFKmdVXvrMrVW/mHCCfS/MtOwIDAQABAoIBAQCTAQHbjmwuHu8e 8 | 2F24x7Tz//UWPT9fbRtK/6RO3ctlCsS/bXCHHARnrGcDdfHq1yv6PS21/UvXtThE 9 | Dn4qO75X9DzgnAFNgEwELjPyVBM4YG2pF3SQ+MJESaI4hgGY8Rws5eMF/qFhdbo1 10 | hATggqFqnQZqWy0DP9wkq8ESk1nYNICehj0d6Mo5uW190TDMD6QrfHg4rDYbgITf 11 | SCmsRdybCASlgOHCrYgjweG9czNoFimhaG8WwP59yfCX0A1TrDJ0toryyopupIre 12 | A+5HHBM2Dk3KylrtVBAPRsM9eGUo4bmz8p6hRkuw7mr321d416MHdIXcHK38EWR0 13 | ZvUWM8QJAoGBAPlPe3ggR9xhEbQJQkOohnZ1hkogE/uxZrcRiUI3pnDNcCXy9Ogt 14 | SYfwxYnHLa5kuynbmCCzSLOtq2DN9QwJ5o+zgRjX9T8DAWub6KFdEnTHhq/ZLF/w 15 | PWPg3Oe8dYDEEcrPLvN25aetY2LrWKsRPFL8//WLJc1+LFRG6Vc1ATftAoGBAOxv 16 | hGxNGrcD5c8g0ZcyeKVbCCRGfp0+mwonnQ25mDyIXNH+PEHa7SPs5dVexA5r0/Ky 17 | lM/jQgs756EvslwA2oukqVz7ehDhJI4RE92OPjpYrAu7HF6eN/fAhUMghs/vAZ6c 18 | YCM6i9emHYHM4mU6H/yLIr+0e2JNf+479bB5hQTHAoGBAOGnFUQXQ7OukE16C+Yd 19 | RQc3PIMfIbcwTJ3qW2f54sY6zAUtMIptYx6NyN35z9kHB3jNb5Y5b9ZhnLqT7/Yj 20 | h/INMQ4BedK8r65sgVR8X1YfukKzuLxlP8uFHa0KIPiZftkoSYDH3vmzsD86cRj1 21 | ErqykCH4/hBO4WSugkkSirXJAoGARXvQcvOF8lsW4nRGpCSVCCNklSSSeSu47JcP 22 | tMTiVIfOn3gTxVbNck1gjgA3pfVSaHTK/v1On3aPb/NQe3FUyM0vaMAO8372+zlR 23 | mT8AUq1Ugm4OvE/LKuhNQZkBhYI7+50BM9k0179d1JOdxRn75IAPSj+EMzOLcTv1 24 | zFMqIGkCgYBm5xT3Gu8fJh/8ztelzrDkGga6UpYKKYjHGFHpaqmDn9sjjCu8X2pG 25 | JUGgyUVj1NkJAtHMS45Ud3upQwxpy2aNmMaQbwzHybvX7EYZHHVuCwsSzaXRtwj2 26 | Q6mG1Ghi0UQ76SPKQr0Vu8Uu+0CAzYAK4IEKeH6BCRjrzHggSpdNzQ== 27 | -----END RSA PRIVATE KEY----- -------------------------------------------------------------------------------- /elements/system-configuration/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmQeA/uyEyFf9DsmwR+OztWb7Hb/uTC+R3xG1QgBvRwhSbpBnyBESGMZZ07bIw5Ib7BUSDzwoeryUqNAhAhir2KLeIYODS39UmTwOIl+rIvhlTxhsIoQHV90pewD2qw0T8KgVMPUDsQ0Bd98E6e5dbxciZp67ihVD0r7srhdSRo8PIc56hJWrD52j5FeiIGEmLXHXiZLOyma1M7j/EmiV81wHAzgql6sihWSZHm3xPZZ712JtXbmHhe3RLFIK13u9PSb3XbuEIdGwkZdzP+vYNE0CsYqwjXjVRrY/APsiEkbSNVzHI5p2W1L7ZMtSOMUqZ1Ve+sytVb+YcIJ9L8y07 trove@devstack -------------------------------------------------------------------------------- /elements/system-configuration/install.d/01-user: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # CONTEXT: GUEST during CONSTRUCTION as ROOT 4 | # PURPOSE: Add the guest image user that will own the trove agent source...if the user does not already exist 5 | 6 | set -e 7 | set -o xtrace 8 | 9 | echo "Adding trove user" 10 | 11 | adduser trove 12 | passwd -d trove 13 | sudo usermod trove -a -G wheel 14 | -------------------------------------------------------------------------------- /elements/system-configuration/post-install.d/10-ntp: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | yum -y install ntp 4 | -------------------------------------------------------------------------------- /elements/system-configuration/post-install.d/20-ssh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # CONTEXT: GUEST during CONSTRUCTION as ROOT 4 | # PURPOSE: take "staged" ssh keys and put them in the home directory 5 | 6 | set -e 7 | set -o xtrace 8 | 9 | yum -y install openssh-server 10 | 11 | echo "Installing the SSH test key to the environment." 12 | mkdir -p /root/.ssh 13 | install -b --mode 0400 /tmp/in_target.d/id_rsa /root/.ssh/ 14 | cat /tmp/in_target.d/id_rsa.pub >> /root/.ssh/authorized_keys 15 | -------------------------------------------------------------------------------- /elements/system-configuration/post-install.d/62-trove-guest-sudoers: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -o xtrace 4 | 5 | # CONTEXT: HOST after IMAGE BUILD as SCRIPT USER 6 | # PURPOSE: add the guest user account to the /etc/sudoers files with NOPASSWD 7 | 8 | # Adds user to the sudoers file so they can do everything w/o a pass 9 | # Some binaries might be under /sbin or /usr/sbin, so make sure sudo will 10 | # see them by forcing PATH 11 | TEMPFILE=`mktemp` 12 | echo "trove ALL=(ALL) NOPASSWD:ALL" > $TEMPFILE 13 | chmod 0440 $TEMPFILE 14 | sudo chown root:root $TEMPFILE 15 | sudo mv $TEMPFILE /etc/sudoers.d/60_trove_guest 16 | -------------------------------------------------------------------------------- /elements/system-configuration/post-install.d/90-yum-update: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o xtrace 5 | 6 | sudo yum -y update 7 | -------------------------------------------------------------------------------- /elements/system-configuration/post-install.d/99-fpaste: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o xtrace 5 | 6 | yum -y install fpaste 7 | -------------------------------------------------------------------------------- /elements/trove-guest/install.d/15-install-trove: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o xtrace 5 | 6 | if [ "${DISTRO}" = "rhel" ]; then 7 | # NOTE(vkmc) This is necessary for now. Waiting for the release. 8 | yum -y install wget 9 | wget http://rhos-release.virt.bos.redhat.com/repos/rhos-release/rhos-release-latest.noarch.rpm 10 | yum -y --nogpgcheck localinstall rhos-release-latest.noarch.rpm 11 | rhos-release 7 12 | fi 13 | 14 | if [ "${DISTRO}" = "centos" ]; then 15 | yum -y install https://rdo.fedorapeople.org/rdo-release.rpm wget 16 | yum -y update 17 | sed -i -e 's/^Defaults.*requiretty/# Defaults requiretty/g' /etc/sudoers 18 | sed -i -e 's/^enabled=0/enabled=1/g' /etc/yum.repos.d/rdo-testing.repo 19 | sed -i -e 's/^enabled=1/enabled=0/g' /etc/yum.repos.d/rdo-release.repo 20 | fi 21 | 22 | yum -y install openstack-trove-guestagent python-troveclient python-netifaces pexpect 23 | -------------------------------------------------------------------------------- /elements/trove-guest/openstack-trove-guestagent.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=OpenStack Trove Guest 3 | After=syslog.target network.target cloud-init.service 4 | 5 | [Service] 6 | Type=simple 7 | User=trove 8 | ExecStart=/usr/bin/trove-guestagent --config-file /etc/trove/conf.d/trove-guestagent.conf --config-file /etc/trove/conf.d/guest_info.conf 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /elements/trove-guest/post-install.d/30-register-guest-service: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -o xtrace 5 | 6 | # Copy service file 7 | dd if=/tmp/in_target.d/openstack-trove-guestagent.service of=/usr/lib/systemd/system/openstack-trove-guestagent.service 8 | 9 | # Configuring permissions 10 | mkdir -p /etc/trove/conf.d 11 | chown -R trove:trove /etc/trove 12 | chown trove:trove /usr/share/trove 13 | chown trove:trove /var/log/trove 14 | 15 | # Enable and start service 16 | systemctl enable openstack-trove-guestagent.service 17 | systemctl start openstack-trove-guestagent.service 18 | -------------------------------------------------------------------------------- /load_trove_image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | err() { 6 | echo "${0##*/}: $@" >&2 7 | } 8 | 9 | print_usage() { 10 | echo "Usage: ${0##*/} [-s datastore] [-v datastore_version] [-p packages] [-i image id]" 11 | echo "Options:" 12 | echo " -s | --datastore: name of the datastore. Possible options are mysql, mongodb, or postgresql." 13 | echo " -v | --datastore-version: name of the datastore version." 14 | echo " -p | --packages: packages required by the datastore version that are installed on the guest image." 15 | echo " -i | --image-id: ID of the image used to create an instance of the datastore version." 16 | echo " -h | --help: print this usage message and exit." 17 | echo "" 18 | echo "Usage example: load_trove_image -s mysql -v fedora-mysql5.5 -p mysql-server=5.5 -i cf82462a-956c-4609-8413-a1eba1ba9dbd" 19 | } 20 | 21 | check_root() { 22 | local user=$(/usr/bin/id -u) 23 | if [ ${user} -ne 0 ]; then 24 | err "You need to be root (uid 0) to run this script." 25 | exit 1 26 | fi 27 | } 28 | 29 | parse_arguments() { 30 | while [[ $# > 0 ]]; do 31 | case "$1" in 32 | -s|--datastore) 33 | export DATASTORE=$2 34 | valid_datastore_control 35 | shift 2 36 | ;; 37 | -v|--datastore-version) 38 | export DATASTORE_VERSION=$2 39 | shift 2 40 | ;; 41 | -p|--packages) 42 | export PACKAGES=$2 43 | shift 2 44 | ;; 45 | -i|--image-id) 46 | export IMAGE_ID=$2 47 | shift 2 48 | ;; 49 | -h|--help) 50 | print_usage 51 | exit 0 52 | ;; 53 | -*) 54 | err "Error: Unknown option: $1." 55 | exit 1 56 | ;; 57 | *) 58 | break 59 | ;; 60 | esac 61 | done 62 | } 63 | 64 | valid_datastore_control() { 65 | if [ "${DATASTORE}" != "mysql" ] && [ "${DATASTORE}" != "mongodb" ] && [ "${DATASTORE}" != "postgresql" ]; then 66 | err "Datastore ${DATASTORE} not supported. Valid options are mysql, mongodb, or postgresql." 67 | exit 1 68 | fi 69 | } 70 | 71 | required_params_control() { 72 | : ${DATASTORE:?"Name of the system to use is required. Possible options are fedora, centos or rhel."} 73 | : ${DATASTORE_VERSION:?"Version of the datastore to use required."} 74 | : ${PACKAGES:?"Packages required by the datastore version required."} 75 | : ${IMAGE_ID:?"ID of image to use required."} 76 | } 77 | 78 | main() { 79 | check_root 80 | parse_arguments "$@" 81 | required_params_control 82 | trove-manage datastore_update ${DATASTORE} "" 83 | trove-manage datastore_version_update ${DATASTORE} ${DATASTORE_VERSION} ${DATASTORE} ${IMAGE_ID} ${PACKAGES} 1 84 | trove-manage datastore_update ${DATASTORE} ${DATASTORE_VERSION} 85 | exit 0 86 | } 87 | 88 | main "$@" 89 | --------------------------------------------------------------------------------