diff --git a/.gitignore b/.gitignore index 52efb1d8..f7fcdfca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -*~ -validate/env.sh -validate/.terraform -validate/terraform.* -validate/ip.tmp -openshift-ansible + +/.idea/ +/installcentos.iml diff --git a/install-openshift.sh b/install-openshift.sh index af61833d..ecad5b95 100755 --- a/install-openshift.sh +++ b/install-openshift.sh @@ -1,17 +1,15 @@ #!/bin/bash -## see: https://youtu.be/aqXSbDZggK4 - ## Default variables to use -export INTERACTIVE=${INTERACTIVE:="true"} -export PVS=${INTERACTIVE:="true"} -export DOMAIN=${DOMAIN:="$(curl -s ipinfo.io/ip).nip.io"} -export USERNAME=${USERNAME:="$(whoami)"} -export PASSWORD=${PASSWORD:=password} +export IP=${IP:="$(hostname -I | awk '{print $2}')"} +export DOMAIN=${DOMAIN:="$IP.nip.io"} +export USER_NAME=${USER_NAME:="admin"} +export PASSWORD=${PASSWORD:="password"} export VERSION=${VERSION:="3.11"} -export SCRIPT_REPO=${SCRIPT_REPO:="https://raw.githubusercontent.com/gshipley/installcentos/master"} -export IP=${IP:="$(ip route get 8.8.8.8 | awk '{print $NF; exit}')"} +export SCRIPT_REPO=${SCRIPT_REPO:="https://raw.githubusercontent.com/cmcornejocrespo/installcentos/master"} export API_PORT=${API_PORT:="8443"} +export METRICS="False" +export LOGGING="False" export LETSENCRYPT=${LETSENCRYPT:="false"} export MAIL=${MAIL:="example@email.com"} @@ -72,7 +70,7 @@ fi echo "******" echo "* Your domain is $DOMAIN " echo "* Your IP is $IP " -echo "* Your username is $USERNAME " +echo "* Your username is $USER_NAME " echo "* Your password is $PASSWORD " echo "* OpenShift version: $VERSION " echo "* Enable HTTPS with Let's Encrypt: $LETSENCRYPT " @@ -99,7 +97,7 @@ yum -y install epel-release # Disable the EPEL repository globally so that is not accidentally used during later steps of the installation sed -i -e "s/^enabled=1/enabled=0/" /etc/yum.repos.d/epel.repo -systemctl | grep "NetworkManager.*running" +systemctl | grep "NetworkManager.*running" if [ $? -eq 1 ]; then systemctl start NetworkManager systemctl enable NetworkManager @@ -114,28 +112,11 @@ yum -y --enablerepo=epel install ansible.rpm [ ! -d openshift-ansible ] && git clone https://github.com/openshift/openshift-ansible.git -b release-${VERSION} --depth=1 cat < /etc/hosts -127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 +127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 -${IP} $(hostname) console console.${DOMAIN} +${IP} $(hostname) console console.${DOMAIN} EOD -if [ -z $DISK ]; then - echo "Not setting the Docker storage." -else - cp /etc/sysconfig/docker-storage-setup /etc/sysconfig/docker-storage-setup.bk - - echo DEVS=$DISK > /etc/sysconfig/docker-storage-setup - echo VG=DOCKER >> /etc/sysconfig/docker-storage-setup - echo SETUP_LVM_THIN_POOL=yes >> /etc/sysconfig/docker-storage-setup - echo DATA_SIZE="100%FREE" >> /etc/sysconfig/docker-storage-setup - - systemctl stop docker - - rm -rf /var/lib/docker - wipefs --all $DISK - docker-storage-setup -fi - systemctl restart docker systemctl enable docker @@ -145,9 +126,6 @@ if [ ! -f ~/.ssh/id_rsa ]; then ssh -o StrictHostKeyChecking=no root@$IP "pwd" < /dev/null fi -export METRICS="True" -export LOGGING="True" - memory=$(cat /proc/meminfo | grep MemTotal | sed "s/MemTotal:[ ]*\([0-9]*\) kB/\1/") if [ "$memory" -lt "4194304" ]; then @@ -224,36 +202,15 @@ touch /etc/origin/master/htpasswd ansible-playbook -i inventory.ini openshift-ansible/playbooks/prerequisites.yml ansible-playbook -i inventory.ini openshift-ansible/playbooks/deploy_cluster.yml -htpasswd -b /etc/origin/master/htpasswd ${USERNAME} ${PASSWORD} -oc adm policy add-cluster-role-to-user cluster-admin ${USERNAME} - -if [ "$PVS" = "true" ]; then - - curl -o vol.yaml $SCRIPT_REPO/vol.yaml - - for i in `seq 1 200`; - do - DIRNAME="vol$i" - mkdir -p /mnt/data/$DIRNAME - chcon -Rt svirt_sandbox_file_t /mnt/data/$DIRNAME - chmod 777 /mnt/data/$DIRNAME - - sed "s/name: vol/name: vol$i/g" vol.yaml > oc_vol.yaml - sed -i "s/path: \/mnt\/data\/vol/path: \/mnt\/data\/vol$i/g" oc_vol.yaml - oc create -f oc_vol.yaml - echo "created volume $i" - done - rm oc_vol.yaml -fi +htpasswd -b /etc/origin/master/htpasswd ${USER_NAME} ${PASSWORD} +oc adm policy add-cluster-role-to-user cluster-admin ${USER_NAME} echo "******" echo "* Your console is https://console.$DOMAIN:$API_PORT" -echo "* Your username is $USERNAME " +echo "* Your username is $USER_NAME " echo "* Your password is $PASSWORD " echo "*" echo "* Login using:" echo "*" -echo "$ oc login -u ${USERNAME} -p ${PASSWORD} https://console.$DOMAIN:$API_PORT/" -echo "******" - -oc login -u ${USERNAME} -p ${PASSWORD} https://console.$DOMAIN:$API_PORT/ +echo "$ oc login -u ${USER_NAME} -p ${PASSWORD} https://console.$DOMAIN:$API_PORT/ --insecure-skip-tls-verify" +echo "******" \ No newline at end of file diff --git a/inventory.ini b/inventory.ini index 7562f4ab..82df1638 100644 --- a/inventory.ini +++ b/inventory.ini @@ -1,47 +1,47 @@ -[OSEv3:children] -masters -nodes -etcd - -[masters] -${IP} openshift_ip=${IP} openshift_schedulable=true - -[etcd] -${IP} openshift_ip=${IP} - -[nodes] -${IP} openshift_ip=${IP} openshift_schedulable=true openshift_node_group_name="node-config-all-in-one" - -[OSEv3:vars] -openshift_additional_repos=[{'id': 'centos-paas', 'name': 'centos-paas', 'baseurl' :'https://buildlogs.centos.org/centos/7/paas/x86_64/openshift-origin311', 'gpgcheck' :'0', 'enabled' :'1'}] - -ansible_ssh_user=root -enable_excluders=False -enable_docker_excluder=False -ansible_service_broker_install=False - -containerized=True -os_sdn_network_plugin_name='redhat/openshift-ovs-multitenant' -openshift_disable_check=disk_availability,docker_storage,memory_availability,docker_image_availability - -deployment_type=origin -openshift_deployment_type=origin - -template_service_broker_selector={"region":"infra"} -openshift_metrics_image_version="v${VERSION}" -openshift_logging_image_version="v${VERSION}" -openshift_logging_elasticsearch_proxy_image_version="v1.0.0" -openshift_logging_es_nodeselector={"node-role.kubernetes.io/infra":"true"} -logging_elasticsearch_rollout_override=false -osm_use_cockpit=true - -openshift_metrics_install_metrics=${METRICS} -openshift_logging_install_logging=${LOGGING} - -openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider'}] -openshift_master_htpasswd_file='/etc/origin/master/htpasswd' - -openshift_public_hostname=console.${DOMAIN} -openshift_master_default_subdomain=apps.${DOMAIN} -openshift_master_api_port=${API_PORT} -openshift_master_console_port=${API_PORT} +[OSEv3:children] +masters +nodes +etcd + +[masters] +${IP} openshift_ip=${IP} openshift_schedulable=true + +[etcd] +${IP} openshift_ip=${IP} + +[nodes] +${IP} openshift_ip=${IP} openshift_schedulable=true openshift_node_group_name="node-config-all-in-one" + +[OSEv3:vars] +openshift_additional_repos=[{'id': 'centos-paas', 'name': 'centos-paas', 'baseurl' :'https://buildlogs.centos.org/centos/7/paas/x86_64/openshift-origin311', 'gpgcheck' :'0', 'enabled' :'1'}] + +ansible_ssh_user=root +enable_excluders=False +enable_docker_excluder=False +ansible_service_broker_install=False + +containerized=True +os_sdn_network_plugin_name='redhat/openshift-ovs-multitenant' +openshift_disable_check=disk_availability,docker_storage,memory_availability,docker_image_availability + +deployment_type=origin +openshift_deployment_type=origin + +template_service_broker_selector={"region":"infra"} +openshift_metrics_image_version="v${VERSION}" +openshift_logging_image_version="v${VERSION}" +openshift_logging_elasticsearch_proxy_image_version="v1.0.0" +openshift_logging_es_nodeselector={"node-role.kubernetes.io/infra":"true"} +logging_elasticsearch_rollout_override=false +osm_use_cockpit=true + +openshift_metrics_install_metrics=${METRICS} +openshift_logging_install_logging=${LOGGING} + +openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true', 'challenge': 'true', 'kind': 'HTPasswdPasswordIdentityProvider'}] +openshift_master_htpasswd_file='/etc/origin/master/htpasswd' + +openshift_public_hostname=console.${DOMAIN} +openshift_master_default_subdomain=apps.${DOMAIN} +openshift_master_api_port=${API_PORT} +openshift_master_console_port=${API_PORT} \ No newline at end of file diff --git a/user-custom-exports.sh b/user-custom-exports.sh deleted file mode 100644 index 155419a5..00000000 --- a/user-custom-exports.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -export DOMAIN="" -export USERNAME="" -export PASSWORD="" -export SCRIPT_REPO="" -export IP="" -export DISK="" diff --git a/validate/do.tf b/validate/do.tf deleted file mode 100644 index dae76a60..00000000 --- a/validate/do.tf +++ /dev/null @@ -1,35 +0,0 @@ -resource "digitalocean_ssh_key" "openshift" { - name = "openshift" - public_key = "${file("~/.ssh/id_rsa.pub")}" -} - -resource "digitalocean_droplet" "openshift" { - image = "centos-7-x64" - name = "openshift" - region = "ams3" - size = "s-6vcpu-16gb" - ssh_keys = ["${digitalocean_ssh_key.openshift.fingerprint}"] - monitoring = true - - provisioner "file" { - source = "validate.sh" - destination = "/root/validate.sh" - } - - provisioner "file" { - source = "run.sh" - destination = "/root/run.sh" - } - - provisioner "remote-exec" { - inline = [ - "chmod +x /root/validate.sh", - "/root/validate.sh", - ] - } - - provisioner "local-exec" { - command = "echo ${digitalocean_droplet.openshift.ipv4_address} > ip.tmp" - } - -} \ No newline at end of file diff --git a/validate/run.sh b/validate/run.sh deleted file mode 100755 index f0912c4d..00000000 --- a/validate/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -curl https://raw.githubusercontent.com/gshipley/installcentos/master/install-openshift.sh | INTERACTIVE=false /bin/bash \ No newline at end of file diff --git a/validate/start.sh b/validate/start.sh deleted file mode 100755 index cbbace4e..00000000 --- a/validate/start.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -source env.sh - -terraform init - -terraform apply -auto-approve - -terraform show - -ssh -t root@`cat ip.tmp` 'tmux attach' \ No newline at end of file diff --git a/validate/stop.sh b/validate/stop.sh deleted file mode 100755 index b59265ea..00000000 --- a/validate/stop.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -source env.sh - -terraform destroy -auto-approve \ No newline at end of file diff --git a/validate/validate.sh b/validate/validate.sh deleted file mode 100755 index c9c28e1f..00000000 --- a/validate/validate.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -yum -y update - -yum -y install tmux - -tmux new-session -d -s installcentos - -chmod +x /root/run.sh - -tmux send -t installcentos /root/run.sh ENTER \ No newline at end of file diff --git a/vol.yaml b/vol.yaml deleted file mode 100644 index 1fe2bee4..00000000 --- a/vol.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: vol -spec: - capacity: - storage: 500Gi - accessModes: - - ReadWriteOnce - - ReadWriteMany - persistentVolumeReclaimPolicy: Retain - hostPath: - path: /mnt/data/vol