Skip to content

Instantly share code, notes, and snippets.

@danpawlik
Last active March 3, 2020 09:26
Show Gist options
  • Save danpawlik/9e832d18520899aec755902489298455 to your computer and use it in GitHub Desktop.
Save danpawlik/9e832d18520899aec755902489298455 to your computer and use it in GitHub Desktop.
Openshift quick setup
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
yum -y install centos-release-openshift-origin epel-release git pyOpenSSL
yum -y install openshift-ansible
yum install -y docker
systemctl start docker
systemctl enable docker
cat << EOF | sudo tee -a /etc/hosts
$(ip route get 1.1.1.1 | grep -oP 'src \K\S+') controller.test.local node01.test.local
EOF
if [ ! -f "/root/.ssh/id_rsa" ]; then
ssh-keygen -q -N "" -f /root/.ssh/id_rsa
cat /root/.ssh/id_rsa.pub | tee -a /root/.ssh/authorized_keys
chmod 0600 /root/.ssh/authorized_keys
cat << EOF | tee /root/.ssh/config
Host controller
Hostname controller.test.local
User root
Host node01
Hostname node01.test.local
User root
EOF
chmod 600 /root/.ssh/config
fi
ssh-keyscan -t ed25519 node01.test.local | tee -a /root/.ssh/known_hosts
ssh-keyscan -t ed25519 controller.test.local | tee -a /root/.ssh/known_hosts
ssh-copy-id node01
cat << EOF | sudo tee /etc/ansible/hosts
[OSEv3:children]
masters
nodes
etcd
[OSEv3:vars]
ansible_ssh_user=root
ansible_become=true
openshift_deployment_type=origin
debug_level=8
containerized=false
openshift_disable_check=memory_availability,disk_availability,docker_storage,docker_storage_driver,docker_image_availability,package_version,package_availability,package_update
openshift_hosted_registry_cert_expire_days=36500
openshift_ca_cert_expire_days=36500
openshift_node_cert_expire_days=36500
openshift_master_cert_expire_days=36500
os_firewall_enabled=False
deployment_subtype=registry
openshift_hosted_infra_selector=""
[masters]
controller.test.local
[etcd]
controller.test.local
[nodes]
controller.test.local openshift_node_group_name="node-config-all-in-one"
EOF
pip3 install ansible==2.7.1
pip install ansible==2.7.1
ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/deploy_cluster.yml -e "os_firewall_enabled=False" -e "ansible_python_interpreter=python2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment