This repository was archived by the owner on Nov 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
281 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
from ansible.module_utils.basic import * | ||
|
||
EXAMPLES = ''' | ||
- rbdinfo: | ||
info: 'next step download image.tgz' | ||
''' | ||
|
||
def main(): | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
info=dict(type='str', default='The next task may take some time to execute'), | ||
), | ||
supports_check_mode=True | ||
) | ||
|
||
infodata = dict(stdout=module.params['info'],changed=False,rc=0,msg=module.params['info']) | ||
module.exit_json(**infodata) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
- name: Rainbond | Copy ssh PrimaryKey | ||
copy: | ||
src: /grdata/services/ssh/id_rsa | ||
dest: /root/.ssh/id_rsa | ||
mode: 600 | ||
backup: yes | ||
|
||
- name: Rainbond | Copy ssh PublicKey | ||
copy: | ||
src: /grdata/services/ssh/id_rsa.pub | ||
dest: /root/.ssh/id_rsa.pub | ||
mode: 644 | ||
backup: yes | ||
|
||
- name: Rainbond | Install ansible Online | ||
shell: "pip install ansible" | ||
when: install_type == "online" | ||
|
||
- name: Rainbond | Install ansible Offline | ||
shell: "yum install -y sshpass python-pip ansible" | ||
when: install_type != "online" | ||
|
||
- name: Rainbond | Add share | ||
template: | ||
src: share.sh.j2 | ||
dest: /tmp/share.sh | ||
mode: 0777 | ||
|
||
- name: Rainbond | Run share | ||
shell: bash /tmp/share.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
echo "{{ MASTER_IP }}:/opt/rainbond/etc/tools /opt/rainbond/etc/tools nfs rw 0 0" >> /etc/fstab | ||
echo "{{ MASTER_IP }}:/opt/rainbond/.init /opt/rainbond/.init nfs rw 0 0" >> /etc/fstab | ||
echo "{{ MASTER_IP }}:/opt/rainbond/rainbond-ansible /opt/rainbond/rainbond-ansible nfs rw 0 0">> /etc/fstab | ||
|
||
mount -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
prepare(){ | ||
# IP={{ lbip }} | ||
IP=$(cat /opt/rainbond/.init/domain.yaml | grep iip | awk -F ': ' '{print $2}') | ||
ssl_ca_cert=$(cat {{ region_ca_dir }}/ca.pem) | ||
key_file=$(cat {{ region_ca_dir }}/client.key.pem) | ||
cert_file=$(cat {{ region_ca_dir }}/client.pem) | ||
DOMAIN={{ app_domain }} | ||
cat > /tmp/region_info.sql <<EOF | ||
INSERT INTO \`region_info\` ( \`region_id\`, \`region_name\`, \`region_alias\`, \`url\`, \`token\`, \`status\`, \`desc\`, \`wsurl\`, \`httpdomain\`, \`tcpdomain\`, \`scope\`, \`ssl_ca_cert\`,\`cert_file\`,\`key_file\`) VALUES('asdasdasdasdasdasdasdasdas', 'rainbond', '默认私有数据中心', 'https://region.goodrain.me:8443', NULL, '1', '当前数据中心是默认安装添加的数据中心', 'ws://$IP:6060', '$DOMAIN', '$IP', 'private','$ssl_ca_cert','$cert_file','$key_file'); | ||
EOF | ||
|
||
} | ||
|
||
create_db(){ | ||
docker exec rbd-db mysql -e "grant all on *.* to '{{ db_user }}'@'%' identified by '{{ db_pass }}' with grant option; flush privileges";docker exec rbd-db mysql -e "delete from mysql.user where user=''; flush privileges" | ||
docker exec rbd-db mysql -e "CREATE DATABASE IF NOT EXISTS region DEFAULT CHARSET utf8 COLLATE utf8_general_ci;" | ||
docker exec rbd-db mysql -e "CREATE DATABASE IF NOT EXISTS console DEFAULT CHARSET utf8 COLLATE utf8_general_ci;" | ||
} | ||
|
||
init(){ | ||
for ((i=1;i<=6;i++)) | ||
do | ||
docker exec rbd-db mysql -e "show databases;" | ||
status=$? | ||
[ "$status" -eq 0 ] && ( | ||
create_db | ||
for ((i=1;i<=60;i++ ));do | ||
sleep 5 | ||
uiready=$(docker ps | grep app-ui) | ||
[ ! -z "$uiready" ] && break | ||
done | ||
[ ! -f "/opt/rainbond/.init/.ui.init" ] && ( | ||
prepare | ||
docker exec rbd-app-ui python /app/ui/manage.py migrate | ||
[ "$?" -eq 0 ] && touch /opt/rainbond/.init/.ui.init | ||
) | ||
[ -f "/opt/rainbond/.init/.ui.init" ] && ( | ||
docker cp /tmp/init.sql rbd-db:/root | ||
docker exec rbd-db mysql -e "use console;truncate table console_sys_config" | ||
docker exec rbd-db mysql -e "use console;source /root/init.sql;" | ||
check=$(docker exec rbd-db mysql -e "select wsurl from console.region_info where region_id='asdasdasdasdasdasdasdasdas';") | ||
if [ -z "$check" ];then | ||
docker cp /tmp/region_info.sql rbd-db:/root | ||
docker exec rbd-db mysql -e "use console;source /root/region_info.sql;" | ||
fi | ||
) | ||
) && break | ||
[ "$status" -ne 0 ] && ( | ||
systemctl stop rbd-db && rm -rf /opt/rainbond/data/rbd-db | ||
sleep 20 | ||
) | ||
done | ||
|
||
} | ||
|
||
check(){ | ||
check=$(docker exec rbd-db mysql -e "select wsurl from console.region_info where region_id='asdasdasdasdasdasdasdasdas';") | ||
if [ -z "$check" ];then | ||
init | ||
exit 1 | ||
fi | ||
} | ||
|
||
case $1 in | ||
check) | ||
check | ||
;; | ||
*) | ||
init | ||
;; | ||
esac |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.