huaweicloud

This commit is contained in:
qiaofeng1227 2023-06-25 11:01:50 +08:00
parent 0cbf46b485
commit 23dc596a0a
3 changed files with 81 additions and 70 deletions

View file

@ -1,2 +1,2 @@
# install Cloud Agent, default is false
cloud_agent: False
cloud_agent: true

View file

@ -1,92 +1,91 @@
##
- name: Check Cloud
shell : |
shell: |
if [ -f "/etc/waagent.conf" ];then echo "azure";fi
if [ -d "/usr/local/aegis" ];then echo "alicloud";fi
if [ -f "/snap/bin/amazon-ssm-agent.ssm-cli" ];then echo "aws";fi
if [ -f "/usr/bin/amazon-ssm-agent" ];then echo "aws";fi
if [ -d "/CloudrResetPwdAgent" ];then echo "huaiwei";fi
register: cloud
- debug:
msg: "Cloud platform is {{ cloud.stdout}}"
- block:
- name: Change ubuntu service name
shell: |
ln -sf /usr/lib/systemd/system/walinuxagent.service /usr/lib/systemd/system/waagent.service
systemctl daemon-reload
when: ansible_os_family == 'Debian'
- name: ResourceDisk EnableSwap
lineinfile:
dest: /etc/waagent.conf
regexp: 'ResourceDisk.Format=n'
line: "ResourceDisk.Format=y"
state: present
- name: Change ubuntu service name
shell: |
ln -sf /usr/lib/systemd/system/walinuxagent.service /usr/lib/systemd/system/waagent.service
systemctl daemon-reload
when: ansible_os_family == 'Debian'
- name: ResourceDisk EnableSwap
lineinfile:
dest: /etc/waagent.conf
regexp: 'ResourceDisk.EnableSwap=n'
line: "ResourceDisk.EnableSwap=y"
state: present
- name: ResourceDisk EnableSwap
lineinfile:
dest: /etc/waagent.conf
regexp: "ResourceDisk.Format=n"
line: "ResourceDisk.Format=y"
state: present
- name: ResourceDisk SwapSizeMB
lineinfile:
dest: /etc/waagent.conf
regexp: 'ResourceDisk.SwapSizeMB=0'
line: "ResourceDisk.SwapSizeMB=4096"
state: present
- name: ResourceDisk EnableSwap
lineinfile:
dest: /etc/waagent.conf
regexp: "ResourceDisk.EnableSwap=n"
line: "ResourceDisk.EnableSwap=y"
state: present
- name: Restart waagnet
service:
name: waagent
state: restarted
enabled: yes
- name: ResourceDisk SwapSizeMB
lineinfile:
dest: /etc/waagent.conf
regexp: "ResourceDisk.SwapSizeMB=0"
line: "ResourceDisk.SwapSizeMB=4096"
state: present
- name: Restart waagnet
service:
name: waagent
state: restarted
enabled: yes
when: cloud.stdout == 'azure'
- block:
- name: AWS Configure
apt:
name: ec2-instance-connect
update_cache: yes
when: ansible_os_family == 'Debian'
- name: AWS Configure
apt:
name: ec2-instance-connect
update_cache: yes
when: ansible_os_family == 'Debian'
- name: AWS Configure
yum:
name: ec2-instance-connect
when: ansible_os_family == 'RedHat'
- name: Start ec2-instance-connect
service:
name: ec2-instance-connect
state: started
enabled: yes
failed_when: False
- name: AWS Configure
yum:
name: ec2-instance-connect
when: ansible_os_family == 'RedHat'
- name: Start ec2-instance-connect
service:
name: ec2-instance-connect
state: started
enabled: yes
failed_when: False
when: cloud.stdout == 'aws'
# install cloud agent
- block:
- name: Install Aliyun Aqs and aliyun_assist
shell: |
wget "https://aegis.alicdn.com/download/install/2.0/linux/AliAqsInstall_64.sh" && chmod +x AliAqsInstall_64.sh && ./AliAqsInstall_64.sh sJmepE
wget "https://aliyun-client-assist.oss-accelerate.aliyuncs.com/linux/aliyun_assist_latest.rpm"
rpm -ivh --force aliyun_assist_latest.rpm
#wget "https://aliyun-client-assist.oss-accelerate.aliyuncs.com/linux/aliyun_assist_latest.deb"
#dpkg -r aliyun-assist
systemctl restart aliyun.service
when: cloud.stdout == 'alicloud'
- name: Install Aliyun Aqs and aliyun_assist
shell: |
wget "https://aegis.alicdn.com/download/install/2.0/linux/AliAqsInstall_64.sh" && chmod +x AliAqsInstall_64.sh && ./AliAqsInstall_64.sh sJmepE
wget "https://aliyun-client-assist.oss-accelerate.aliyuncs.com/linux/aliyun_assist_latest.rpm"
rpm -ivh --force aliyun_assist_latest.rpm
#wget "https://aliyun-client-assist.oss-accelerate.aliyuncs.com/linux/aliyun_assist_latest.deb"
#dpkg -r aliyun-assist
systemctl restart aliyun.service
when: cloud.stdout == 'alicloud'
- name: Install huawei agent
shell: curl -k -O 'https://hss-agent.ap-southeast-1.myhuaweicloud.com:10180/package/agent/linux/x86/hostguard.x86_64.deb' && echo 'MASTER_IP=hss-agent.ap-southeast-1.myhuaweicloud.com:10180' > hostguard_setup_config.conf && echo 'SLAVE_IP=hss-agent-slave.ap-southeast-1.myhuaweicloud.com:10180' >> hostguard_setup_config.conf && echo 'ORG_ID=' >> hostguard_setup_config.conf && dpkg -i hostguard.x86_64.deb && rm -f hostguard_setup_config.conf && rm -f hostguard.x86_64.deb
when: ansible_os_family == "RedHat" and cloud.stdout == 'huawei'
- name: Install huawei agent
shell: curl -k -O 'https://hss-agent.ap-southeast-1.myhuaweicloud.com:10180/package/agent/linux/x86/hostguard.x86_64.rpm' && echo 'MASTER_IP=hss-agent.ap-southeast-1.myhuaweicloud.com:10180' > hostguard_setup_config.conf && echo 'SLAVE_IP=hss-agent-slave.ap-southeast-1.myhuaweicloud.com:10180' >> hostguard_setup_config.conf && echo 'ORG_ID=' >> hostguard_setup_config.conf && rpm -ivh hostguard.x86_64.rpm && rm -f hostguard_setup_config.conf && rm -f hostguard.x86_64.rpm
when: ansible_os_family == "Debian" and cloud.stdout == 'huawei'
- name: Install HUAWEICLOUD Agent
shell: wget https://telescope-ap-southeast-1.obs.ap-southeast-1.myhuaweicloud.com/scripts/agentBatchPackage.sh && chmod 755 agentBatchPackage.sh && ./agentBatchPackage.sh
args:
chdir: /usr/local
when: cloud.stdout == 'huawei'
when: cloud_agent

View file

@ -151,8 +151,20 @@ fi
InstallDocker(){
echo "Prepare to install Docker ..."
if command -v docker &> /dev/null
then
echo "Docker is installed, update..."
if command -v apt > /dev/null;then
sudo apt -y install --only-upgrade docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif command -v dnf > /dev/null;then
sudo dnf update -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif command -v yum > /dev/null;then
sudo yum update -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
fi
return
else
echo "Docker is not installed, start to install..."
fi
if [ "$os_type" == 'CentOS' ];then
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
fi