首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用剧本Ansible安装mysql客户端和服务器

无法使用剧本Ansible安装mysql客户端和服务器
EN

DevOps用户
提问于 2021-08-04 12:27:15
回答 1查看 385关注 0票数 1

你知道我怎样才能纠正这个错误吗?

当我试图使用Ansible-playbook、apt模块或shel安装默认的mysql客户端和服务器时,我从节点machibe获得404响应。

事实

我确实可以安装另一个软件,如htop,如果我使用shel:选项,我也会遇到同样的错误,但是当我通过ssh安装软件包时,效果会很好。有问题的节点已经安装了ansible,我purge它检查一下是否可能是问题,没有帮助我。

我有两个节点,第二个节点没有遇到相同的问题,它们有相同的/etc/apt/source.list

编辑:我在错误消息中注意到它正在尝试安装mariadb-client-core-10.3_10.3.27-0+deb10u1_amd64.deb而不是name: ['default-mysql-client','default-mysql-server']

Source.list节点

代码语言:javascript
复制
# 

# deb cdrom:[Debian GNU/Linux 10.8.0 _Buster_ - Official amd64 NETINST 20210206-10:34]/ buster main

# deb cdrom:[Debian GNU/Linux 10.8.0 _Buster_ - Official amd64 NETINST 20210206-10:34]/ buster main

deb http://deb.debian.org/debian/ buster main
deb-src http://deb.debian.org/debian/ buster main

deb http://security.debian.org/debian-security buster/updates main
deb-src http://security.debian.org/debian-security buster/updates main

# buster-updates, previously known as 'volatile'
deb http://deb.debian.org/debian/ buster-updates main
deb-src http://deb.debian.org/debian/ buster-updates main

# Added by aby for ansible course
#deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.

主机

代码语言:javascript
复制
ansible --version

ansible [core 2.11.3] 
  python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
  jinja version = 2.11.2
  libyaml = True
代码语言:javascript
复制
lsb_release -a
Debian GNU/Linux 10 (buster)

节点

代码语言:javascript
复制
lsb_release -a
Debian GNU/Linux 10 (buster)

Playbook

代码语言:javascript
复制
- name: Deploy a web app
  hosts: db_and_web_server1 , db_and_web_server2
  become: yes
  tasks:
    - name: Update and Upgrade system
      apt:
        upgrade: yes
        update_cache: yes
        cache_valid_time: 0
        
    - name: Install all required dependencies 
      apt: 
        name: ['python', 'python-setuptools', 'python-dev', 'build-essential', 'python-pip','htop']
        update_cache: yes
        state: latest 
  
    - name: Install Mysql and htop
      apt: 
        update_cache: yes
        cache_valid_time: 0
        name: ['default-mysql-client','default-mysql-server'] 
        #state: latest
        #shell: apt install -y default-mysql-client
        #shell: "apt install -y --fix-missing default-mysql-client"
      #ignore_errors: true
      #shell: apt install -f -y 
    - name: Start MySql Service
      service:
        name: mysql
        state: started
        enabled: yes

误差

代码语言:javascript
复制
fatal: [db_and_web_server1]: FAILED! => 
{
    "changed": true,
    "cmd": "apt install -y default-mysql-client",
    "delta": "0:00:00.940517",
    "end": "2021-08-02 11:09:07.829191",
    "msg": "non-zero return code",
    "rc": 100,
    "start": "2021-08-02 11:09:06.888674",
    "stderr": "\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n\nE: Failed to fetch http://deb.debian.org/debian/pool/main/m/mariadb-10.3/mariadb-client-core-10.3_10.3.27-0+deb10u1_amd64.deb  404  Not Found [IP: 2a04:4e42:62::644 80]\nE: Failed to fetch http://deb.debian.org/debian/pool/main/m/mariadb-10.3/mariadb-client-10.3_10.3.27-0+deb10u1_amd64.deb  404  Not Found [IP: 2a04:4e42:62::644 80]\nE: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?",
    "stderr_lines": ["",
        "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.",
        "",
        "E: Failed to fetch http://deb.debian.org/debian/pool/main/m/mariadb-10.3/mariadb-client-core-10.3_10.3.27-0+deb10u1_amd64.deb  404  Not Found [IP: 2a04:4e42:62::644 80]",
        "E: Failed to fetch http://deb.debian.org/debian/pool/main/m/mariadb-10.3/mariadb-client-10.3_10.3.27-0+deb10u1_amd64.deb  404  Not Found [IP: 2a04:4e42:62::644 80]",
        "E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?"
    ],
    "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following additional packages will be installed:\n  libaio1 libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libreadline5\n  mariadb-client-10.3 mariadb-client-core-10.3\nSuggested packages:\n  libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl\nThe following NEW packages will be installed:\n  default-mysql-client libaio1 libconfig-inifiles-perl libdbd-mysql-perl\n  libdbi-perl libreadline5 mariadb-client-10.3 mariadb-client-core-10.3\n0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.\nNeed to get 6,904 kB/7,986 kB of archives.\nAfter this operation, 54.5 MB of additional disk space will be used.\nErr:1 http://deb.debian.org/debian buster/main amd64 mariadb-client-core-10.3 amd64 1:10.3.27-0+deb10u1\n  404  Not Found [IP: 2a04:4e42:62::644 80]\nErr:2 http://deb.debian.org/debian buster/main amd64 mariadb-client-10.3 amd64 1:10.3.27-0+deb10u1\n  404  Not Found [IP: 2a04:4e42:62::644 80]",
    "stdout_lines": [
        "Reading package lists...",
        "Building dependency tree...",
        "Reading state information...",
        "The following additional packages will be installed:",
        "  libaio1 libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libreadline5",
        "  mariadb-client-10.3 mariadb-client-core-10.3",
        "Suggested packages:",
        "  libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl",
        "The following NEW packages will be installed:",
        "  default-mysql-client libaio1 libconfig-inifiles-perl libdbd-mysql-perl",
        "  libdbi-perl libreadline5 mariadb-client-10.3 mariadb-client-core-10.3",
        "0 upgraded, 8 newly installed, 0 to remove and 0 not upgraded.",
        "Need to get 6,904 kB/7,986 kB of archives.",
        "After this operation, 54.5 MB of additional disk space will be used.",
        "Err:1 http://deb.debian.org/debian buster/main amd64 mariadb-client-core-10.3 amd64 1:10.3.27-0+deb10u1",
        "  404  Not Found [IP: 2a04:4e42:62::644 80]",
        "Err:2 http://deb.debian.org/debian buster/main amd64 mariadb-client-10.3 amd64 1:10.3.27-0+deb10u1",
        "  404  Not Found [IP: 2a04:4e42:62::644 80]"
    ]
}
EN

回答 1

DevOps用户

发布于 2021-08-05 23:26:47

也许可以指定在http://deb.debian.org/debian/pool/main/m/mariadb-10.3/上可以看到的其他包名

像这样:

代码语言:javascript
复制
- name: Install Mysql and htop
  apt: 
    update_cache: yes
    cache_valid_time: 0
    state: present
    name: "{{packages}}"
  vars:
    packages:
    - mariadb-server
    - mariadb-client
    - htop
票数 1
EN
页面原文内容由DevOps提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://devops.stackexchange.com/questions/14442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档