Skip to content

Commit

Permalink
Merge pull request #6 from IBM/master
Browse files Browse the repository at this point in the history
sync
  • Loading branch information
hongsenliu authored May 22, 2019
2 parents d1ca15d + 6a906ab commit 5a79f0a
Show file tree
Hide file tree
Showing 24 changed files with 1,227 additions and 47 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
*.sum

#Others
/deploy/hosts/hosts
/web/clui/clui
*.retry
.ssh
*.log
*.status
/bin
Expand Down
58 changes: 55 additions & 3 deletions deploy/allinone.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/bin/bash

DB_PASSWD=passw0rd
NET_DEV=eth0

cland_root_dir=/opt/cloudland
cd $(dirname $0)

[ $PWD != "$cland_root_dir/deploy" ] && echo "Please clone cloudland into /opt" && exit 1

sudo chown -R centos.centos /opt/cloudland
sudo chown -R centos.centos $cland_root_dir
mkdir $cland_root_dir/{bin,deploy,etc,lib6,run,sci,scripts,src,web,cache} $cland_root_dir/cache/{image,instance,meta,router,volume,xml} 2>/dev/null

# Install development tools
sudo yum install -y ansible vim git wget epel-release
Expand Down Expand Up @@ -47,10 +51,20 @@ EOF
}

# Install web
function install_web()
function inst_web()
{
sudo yum -y install golang postgresql
cd $cland_root_dir/deploy
ansible-playbook cloudland.yml --tags database --extra-vars "db_passwd=$DB_PASSWD"
sudo yum -y install golang
sudo chown -R centos.centos /usr/local
sed -i '/export GO/d' ~/.bashrc
echo 'export GOPROXY=https://goproxy.io' >> ~/.bashrc
echo 'export GO111MODULE=on' >> ~/.bashrc
source ~/.bashrc
cd $cland_root_dir/web/clui
go build
cd $cland_root_dir/deploy
ansible-playbook cloudland.yml --tags web --extra-vars "db_passwd=$DB_PASSWD"
}

# Install cloudland
Expand All @@ -62,9 +76,47 @@ function inst_cland()
make install
}

# Generate host file
function gen_hosts()
{
cland_ssh_dir=$cland_root_dir/deploy/.ssh
mkdir -p $cland_ssh_dir
chmod 700 $cland_ssh_dir
if [ ! -f $cland_ssh_dir/cland.key ]; then
yes y | ssh-keygen -t rsa -N "" -f $cland_ssh_dir/cland.key
cat $cland_ssh_dir/cland.key.pub >> ~/.ssh/authorized_keys
fi

myip=$(ifconfig $NET_DEV | grep 'inet ' | awk '{print $2}')
sudo bash -c "sed -i '/$myip $hname/d' /etc/hosts"
hname=$(hostname -s)
sudo bash -c "echo '$myip $hname' >> /etc/hosts"
echo $hname > $cland_root_dir/etc/host.list
cat > $cland_root_dir/deploy/hosts/hosts <<EOF
[hyper]
$hname ansible_host=$myip ansible_ssh_private_key_file=$cland_ssh_dir/cland.key client_id=0
[cland]
$hname ansible_host=$myip ansible_ssh_private_key_file=$cland_ssh_dir/cland.key
[web]
$hname ansible_host=$myip ansible_ssh_private_key_file=$cland_ssh_dir/cland.key
[database]
$hname ansible_host=$myip ansible_ssh_private_key_file=$cland_ssh_dir/cland.key
[imgrepo]
$hname ansible_host=$myip ansible_ssh_private_key_file=$cland_ssh_dir/cland.key
EOF
}

diff /opt/sci/lib64/libsci.so.0.0.0 $cland_root_dir/sci/libsci/.libs/libsci.so.0.0.0
[ $? -ne 0 ] && inst_sci
[ ! -f "$cland_root_dir/grpc/activate.sh" ] && inst_grpc
diff $cland_root_dir/bin/cloudland $cland_root_dir/src/cloudland
[ $? -ne 0 ] && inst_cland

gen_hosts
cd $cland_root_dir/deploy
ansible-playbook cloudland.yml --tags be_pkg,be_srv,fe_srv,imgrepo --extra-vars "network_device=$NET_DEV"
inst_web
18 changes: 18 additions & 0 deletions deploy/cloudland.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,21 @@
hosts: cland
roles:
- {role: cland, tags: [cland]}

# deploy web
- name: install web
hosts: web
roles:
- {role: web, tags: [web]}

# deploy database
- name: install database
hosts: database
roles:
- {role: database, tags: [database]}

# deploy image repository
- name: install image repo
hosts: imgrepo
roles:
- {role: imgrepo, tags: [imgrepo]}
13 changes: 11 additions & 2 deletions deploy/hosts/hosts
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
[hyper]
server-0 ansible_host=192.168.10.25
inst-dev ansible_host=192.168.1.128 ansible_ssh_private_key_file=/opt/cloudland/deploy/.ssh/cland.key client_id=0

[cland]
allinone ansible_host=192.168.10.25
inst-dev ansible_host=192.168.1.128 ansible_ssh_private_key_file=/opt/cloudland/deploy/.ssh/cland.key

[web]
inst-dev ansible_host=192.168.1.128 ansible_ssh_private_key_file=/opt/cloudland/deploy/.ssh/cland.key

[database]
inst-dev ansible_host=192.168.1.128 ansible_ssh_private_key_file=/opt/cloudland/deploy/.ssh/cland.key

[imgrepo]
inst-dev ansible_host=192.168.1.128 ansible_ssh_private_key_file=/opt/cloudland/deploy/.ssh/cland.key
2 changes: 0 additions & 2 deletions deploy/prepare.retry

This file was deleted.

13 changes: 8 additions & 5 deletions deploy/roles/cland/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@

- name: copy service file
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
src: cloudland.service
dest: /lib/systemd/system
mode: preserve
with_items:
- {src: 'cloudland.service', dest: '/lib/systemd/system', owner: 'root'}
- {src: 'cloudland.default', dest: '/etc/sysconfig/cloudland', owner: 'root'}
tags: [fe_srv]

- name: create cloudland environment file
template:
src: cloudland.j2
dest: /etc/sysconfig/cloudland
tags: [fe_srv]

- name: start cloudland
systemd:
name: cloudland
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ SCI_ENABLE_LISTENER=yes
SCI_LISTENER_PORT=9988
#SCI_ENABLE_FAILOVER=yes
SCI_USE_EXTLAUNCHER=yes
GRPC_REMOTE_ENDPOINT=localhost:30060
GRPC_REMOTE_ENDPOINT={{ hostvars[groups['web'][0]]['inventory_hostname'] }}:30060
SCI_SEGMENT_SIZE=1048576
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sci/lib64
6 changes: 6 additions & 0 deletions deploy/roles/database/files/postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

passwd=$1

su - postgres -c "psql -c \"alter user postgres with password '$passwd'\""
su - postgres -c "psql -c 'create database hypercube'"
Loading

0 comments on commit 5a79f0a

Please sign in to comment.