Websoft9Archive / role_common

common role
Other
0 stars 5 forks source link

support debian #26

Closed chendelin1982 closed 2 years ago

chendelin1982 commented 2 years ago
  1. mcloud add debian - ubuntu 20.04 对应
  2. fix and test debian.yml
qiaofeng1227 commented 2 years ago
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-66-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue 22 Feb 2022 02:19:44 PM CST

  System load:  0.5                Processes:             131
  Usage of /:   14.1% of 39.12GB   Users logged in:       1
  Memory usage: 4%                 IPv4 address for eth0: 192.168.1.243
  Swap usage:   0%

216 updates can be installed immediately.
128 of these updates are security updates.
To see these additional updates run: apt list --upgradable

    Welcome to Huawei Cloud Service

Last login: Tue Feb 22 14:19:28 2022 from 47.75.113.190
/usr/bin/xauth:  file /root/.Xauthority does not exist
root@websoft9-docker0-ubuntu20:~# ls
install.sh
root@websoft9-docker0-ubuntu20:~# cat /etc/debian_version
bullseye/sid
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-159-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

 System information disabled due to load higher than 2.0

 * Canonical Livepatch is available for installation.
   - Reduce system reboots and improve kernel security. Activate at:
     https://ubuntu.com/livepatch
New release '20.04.3 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

Last login: Tue Feb 22 15:07:11 2022 from 47.75.113.190
/usr/bin/xauth:  file /home/ubuntu/.Xauthority does not exist
ubuntu@VM-73-203-ubuntu:~$ sudo su
root@VM-73-203-ubuntu:/home/ubuntu# cat /etc/debian_version
buster/sid
root@VM-73-203-ubuntu:/home/ubuntu# 
qiaofeng1227 commented 2 years ago

ubuntu release debian release

qiaofeng1227 commented 2 years ago

image

qiaofeng1227 commented 2 years ago

image

qiaofeng1227 commented 2 years ago

image

qiaofeng1227 commented 2 years ago
root@VM-16-46-debian:~# wget -N https://raw.githubusercontent.com/Websoft9/ansible-linux/main/scripts/install.sh; bash install.sh -r java
--2022-02-22 15:31:57--  https://raw.githubusercontent.com/Websoft9/ansible-linux/main/scripts/install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.111.133, 185.199.108.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3523 (3.4K) [text/plain]
Saving to: ‘install.sh’

install.sh                                                 100%[========================================================================================================================================>]   3.44K  --.-KB/s    in 0s      

Last-modified header missing -- time-stamps turned off.
2022-02-22 15:31:57 (43.7 MB/s) - ‘install.sh’ saved [3523/3523]
java

Pre-installation is starting, please wait for 1-3 minutes...
gpg: keybox '/tmp/tmp5bm2c_38/pubring.gpg' created
gpg: /tmp/tmp5bm2c_38/trustdb.gpg: trustdb created
gpg: key 93C4A3FD7BB9C367: public key "Launchpad PPA for Ansible, Inc." imported
gpg: Total number processed: 1
gpg:               imported: 1
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
gpg: no valid OpenPGP data found.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 570, in update
    res = self._cache.update(fetch_progress, slist,
apt_pkg.Error: E:The repository 'http://ppa.launchpad.net/ansible/ansible/ubuntu jammy Release' does not have a Release file.
qiaofeng1227 commented 2 years ago

TASK [role_common : Update apt repository list cache] **************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to update apt cache: W:Updating from such a repository can't be done securely, and is therefore disabled by default., W:See apt-secure(8) manpage for repository creation and user configuration details., E:The repository 'http://ppa.launchpad.net/ansible/ansible/ubuntu jammy Release' does not have a Release file."}
qiaofeng1227 commented 2 years ago

mcloud add debian image, run ansible-java by mcloud:


    选择服务器规格(2核4G, 2核8G, 4核16G...):  

     0. ecs.c5.large
     1. ecs.g5.large
     2. ecs.g5.xlarge

    选择: 1

    选择操作系统:  

     0.CentOS7.9 
     1.CentOS8.3 
     2.Ubuntu20.04 
     3.Ubuntu18.04 
     4.Ubuntu16.04 
     5.Debian11.2 
     6.OracleLinux8.2 
     7.OracleLinux8.5 
     8.OracleLinux7.8 
     9.OracleLinux7.5 
     10.WindowsServer2019R2Datacenter-zh 
     11.WindowsServer2019R2Datacenter-en 
     12.WindowsServer2016R2Datacenter-zh 
     13.WindowsServer2016R2Datacenter-en 
     14.WindowsServer2012R2Datacenter-zh 
     15.WindowsServer2012R2Datacenter-en 

    选择: 5

    输入Github上的项目名称:java

    已匹配到项目:ansible-java

    输入版本标号:test

   您即将在 【阿里云】 上部署:javatest on Debian11.2。所选正确吗?

     0. 确认 
     1. 重做 
     2. 退出 

    选择:0

【2/5】准备部署服务器及其环境(可能需要5-10分钟):  

创建服务器...
aliyun ecs RunInstances            --InstanceName websoft9-javatest-Debian11.2 --ImageId 'debian_11_2_x64_20G_alibase_20211227.vhd'            --InstanceType ecs.g5.large --RegionId 'cn-hongkong'            --SecurityGroupId 'sg-j6c7epgwcech14ofdt5l'            --VSwitchId 'vsw-j6cpor7vbblzas6ui2pkf'            --InternetMaxBandwidthOut 100            --KeyPairName 'websoft9_auto'            --SpotStrategy SpotAsPriceGo            --output cols=InstanceIdSets.InstanceIdSet[0]  | sed -n '3p'
(0, 'i-j6cj0m6i157grqca695z')

服务器初始化...
sleep 120s
(0, '')

Execute successfully

输出服务器公网IP...
aliyun ecs DescribeInstances            --InstanceIds '["i-j6cj0m6i157grqca695z"]'             --waiter expr='Instances.Instance[0].Status' to=Running             --output cols=Instances.Instance[0].PublicIpAddress.IpAddress[0] | sed -n '3p'
(0, '47.243.241.120')

服务器预装依赖...
aliyun ecs InstallCloudAssistant             --InstanceId.1=i-j6cj0m6i157grqca695z             --RegionId cn-hongkong &&             aliyun ecs RunCommand             --InstanceId.1=i-j6cj0m6i157grqca695z             --RegionId cn-hongkong             --Name PresforAnsible             --Type RunShellScript             --CommandContent 'curl -o- https://raw.githubusercontent.com/Websoft9/ansible-linux/main/scripts/install.sh | bash'
(0, '{\n\t"RequestId": "CA1C8D7B-658D-345E-B783-667325A8B1FA"\n}\n{\n\t"CommandId": "c-hk02bzr991e61og",\n\t"InvokeId": "t-hk02bzr991lnqps",\n\t"RequestId": "54F919A2-9774-398A-A79F-D7A563F8CC9D"\n}')

Execute successfully

【3/5】安装Ansible自动化项目到服务器:

下载Github上的安装项目(【回车键】重新下载 or 【Ctrl+C】 退出下载)...

git clone --depth 1 https://github.com/websoft9/ansible-java.git
Cloning into 'ansible-java'...
remote: Enumerating objects: 81, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 81 (delta 2), reused 62 (delta 1), pack-reused 0
Unpacking objects: 100% (81/81), done.
Already up-to-date.
- extracting role_common to /tmp/20220222155701-ansible-java/ansible-java/roles/role_common
- role_common was installed successfully
- extracting role_cloud to /tmp/20220222155701-ansible-java/ansible-java/roles/role_cloud
- role_cloud was installed successfully
- extracting role_nginx to /tmp/20220222155701-ansible-java/ansible-java/roles/role_nginx
- role_nginx was installed successfully
- extracting role_mysql to /tmp/20220222155701-ansible-java/ansible-java/roles/role_mysql
- role_mysql was installed successfully
- extracting role_tomcat to /tmp/20220222155701-ansible-java/ansible-java/roles/role_tomcat
- role_tomcat was installed successfully
- extracting role_jdk to /tmp/20220222155701-ansible-java/ansible-java/roles/role_jdk
- role_jdk was installed successfully
- extracting role_docker to /tmp/20220222155701-ansible-java/ansible-java/roles/role_docker
- role_docker was installed successfully
- extracting role_init to /tmp/20220222155701-ansible-java/ansible-java/roles/role_init
- role_init was installed successfully
- extracting role_9panel to /tmp/20220222155701-ansible-java/ansible-java/roles/role_9panel
- role_9panel was installed successfully
- extracting role_inotify_watch to /tmp/20220222155701-ansible-java/ansible-java/roles/role_inotify_watch
- role_inotify_watch was installed successfully
- extracting role_redis to /tmp/20220222155701-ansible-java/ansible-java/roles/role_redis
- role_redis was installed successfully
- extracting role_preend to /tmp/20220222155701-ansible-java/ansible-java/roles/role_preend
- role_preend was installed successfully
- extracting role_end to /tmp/20220222155701-ansible-java/ansible-java/roles/role_end
- role_end was installed successfully
ansible.cfg  CHANGELOG.md  docs  java.yml  License.md  product  project_readme.md  README.md  README-zh.md  requirements.yml  roles  templating.yml  variables.json  vars

进入Ansible自动化安装...
ansible-playbook -i hosts java.yml -e region=1 -e init=0 -e image=websoft9-javatest-Debian11.2
Choose JDK version for this installation 
 1: JDK 6 (only for CentOS7.x)
 2: JDK 7 (only for CentOS7.x, AmazonLinux)
 3: JDK 8
 4: JDK 11
 [3]: 4
Choose Tomcat version for this installation 
 1: Tomcat 8 
 2: Tomcat 9 
 3: Tomcat 10
 [9]: 2
Choose MySQL version for this installation 
 1: MySQL 5.5 (only for CentOS7.x, AmazonLinux)
 2: MySQL 5.6 (only for CentOS7.x, AmazonLinux, Ubuntu16.04 )
 3: MySQL 5.7
 4: MySQL 8.0
 [3]: 3

PLAY [Java] ******************************************************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************************************************************************************************************************
[WARNING]: Platform linux on host 47.243.241.120 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [47.243.241.120]

TASK [include_vars] **********************************************************************************************************************************************************************************************************************************************************
ok: [47.243.241.120]

TASK [debug] *****************************************************************************************************************************************************************************************************************************************************************
ok: [47.243.241.120] => {
    "msg": "Java will be installed, MySQL version is 5.7, JDK version is 11, Tomcat is 9, region code is 1"
}

TASK [role_common : Sleep OK] ************************************************************************************************************************************************************************************************************************************************
changed: [47.243.241.120]

TASK [role_common : debug] ***************************************************************************************************************************************************************************************************************************************************
ok: [47.243.241.120] => {
    "msg": "Will install components on Debian"
}
included: /tmp/20220222155701-ansible-java/ansible-java/roles/role_common/tasks/Debian.yml for 47.243.241.120

TASK [role_common : Update apt repository list cache] ************************************************************************************************************************************************************************************************************************
[WARNING]: Updating cache and auto-installing missing dependency: python-apt
fatal: [47.243.241.120]: FAILED! => {"changed": false, "cmd": "apt-get update", "msg": "E: The repository 'http://ppa.launchpad.net/ansible/ansible/ubuntu jammy Release' does not have a Release file.", "rc": 100, "stderr": "E: The repository 'http://ppa.launchpad.net/ansible/ansible/ubuntu jammy Release' does not have a Release file.\n", "stderr_lines": ["E: The repository 'http://ppa.launchpad.net/ansible/ansible/ubuntu jammy Release' does not have a Release file."], "stdout": "Hit:1 http://mirrors.cloud.aliyuncs.com/debian bullseye InRelease\nHit:2 http://mirrors.cloud.aliyuncs.com/debian bullseye-updates InRelease\nHit:3 http://mirrors.cloud.aliyuncs.com/debian bullseye-proposed-updates InRelease\nHit:4 http://mirrors.cloud.aliyuncs.com/debian bullseye-backports InRelease\nHit:5 http://mirrors.cloud.aliyuncs.com/debian-security bullseye-security InRelease\nIgn:6 http://ppa.launchpad.net/ansible/ansible/ubuntu jammy InRelease\nErr:7 http://ppa.launchpad.net/ansible/ansible/ubuntu jammy Release\n  404  Not Found [IP: 91.189.95.85 80]\nReading package lists...\n", "stdout_lines": ["Hit:1 http://mirrors.cloud.aliyuncs.com/debian bullseye InRelease", "Hit:2 http://mirrors.cloud.aliyuncs.com/debian bullseye-updates InRelease", "Hit:3 http://mirrors.cloud.aliyuncs.com/debian bullseye-proposed-updates InRelease", "Hit:4 http://mirrors.cloud.aliyuncs.com/debian bullseye-backports InRelease", "Hit:5 http://mirrors.cloud.aliyuncs.com/debian-security bullseye-security InRelease", "Ign:6 http://ppa.launchpad.net/ansible/ansible/ubuntu jammy InRelease", "Err:7 http://ppa.launchpad.net/ansible/ansible/ubuntu jammy Release", "  404  Not Found [IP: 91.189.95.85 80]", "Reading package lists..."]}

PLAY RECAP *******************************************************************************************************************************************************************************************************************************************************************
47.243.241.120             : ok=6    changed=1    unreachable=0    failed=1    skipped=2    rescued=0    ignored=0   
qiaofeng1227 commented 2 years ago

need edit https://github.com/Websoft9/ansible-linux/blob/main/scripts/install.sh

cat /etc/os-release |grep VERSION_CODENAME |cut -d= -f2) == bullseye


 if [[ $(cat /etc/os-release |grep VERSION_CODENAME |cut -d= -f2) == focal ]];then
        curl https://bootstrap.pypa.io/2.7/get-pip.py -o /tmp/get-pip.py 1>/dev/null 2>&1
        python2 /tmp/get-pip.py 1>/dev/null 2>&1
  elif [[ $(cat /etc/os-release |grep VERSION_CODENAME |cut -d= -f2) != focal ]];then
        sudo apt-add-repository --yes --update ppa:ansible/ansible
  fi
qiaofeng1227 commented 2 years ago

Debian 添加源

## Note, this file is written by cloud-init on first boot of an instance
## modifications made here will not survive a re-bundle.
## if you wish to make changes you can:
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg
##     or do the same in user-data
## b.) add sources in /etc/apt/sources.list.d
## c.) make changes to template file /etc/cloud/templates/sources.list.debian.tmpl
###

# See http://www.debian.org/releases/stable/i386/release-notes/ch-upgrading.html
# for how to upgrade to newer versions of the distribution.
deb http://mirrors.cloud.aliyuncs.com/debian/ buster main contrib non-free
deb http://mirrors.cloud.aliyuncs.com/debian/ buster-updates main contrib non-free
deb http://mirrors.cloud.aliyuncs.com/debian/ buster-proposed-updates main non-free contrib
deb http://mirrors.cloud.aliyuncs.com/debian/ buster-backports main non-free contrib
## Major bug fix updates produced after the final release of the
## distribution.
deb-src http://mirrors.cloud.aliyuncs.com/debian/ buster-updates main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian/ buster main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian/ buster-proposed-updates main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian/ buster-backports main contrib non-free

deb http://mirrors.cloud.aliyuncs.com/debian-security/ buster/updates main non-free contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian-security/ buster/updates main non-free contrib
## Uncomment the following two lines to add software from the 'backports'
## repository.
## 
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
deb https://mirrors.huaweicloud.com/debian/ stretch main contrib non-free
deb-src https://mirrors.huaweicloud.com/debian/ stretch main contrib non-free
deb https://mirrors.huaweicloud.com/debian/ stretch-updates main contrib non-free
deb-src https://mirrors.huaweicloud.com/debian/ stretch-updates main contrib non-free
deb https://mirrors.huaweicloud.com/debian/ stretch-backports main contrib non-free
deb-src https://mirrors.huaweicloud.com/debian/ stretch-backports main contrib non-free