简体   繁体   English

ansible 剧本有时会失败,但并非总是在 aws ubuntu 20.04 上安装 jre

[英]ansible playbook fails sometimes but not always to install jre on aws ubuntu 20.04

I have an annoying problem.我有一个烦人的问题。 Sometimes, but not always, this playbook fails.有时,但并非总是如此,这个剧本会失败。 I am using this against an ec2 with ubuntu 20.04.我将它用于 ubuntu 20.04 的 ec2。

tasks:
  - name: Update system
    apt:
      update_cache: yes
      force_apt_get: yes
      cache_valid_time: 3600

  - name: Upgrade all apt packages
    apt:
      upgrade: dist
      force_apt_get: yes

    # this failes every now and then
  - name: Ensure jre is installed
    apt:
      name: openjdk-17-jre-headless
      state: present

When it fails, it throws this error.当它失败时,它会抛出这个错误。

 fatal: [default]: FAILED! => {"cache_update_time": 1640556142, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"       install 'openjdk-17-jre-headless'' failed: E: Unable to correct problems, you have held broken packages.\n", "rc": 100, "stderr": "E: Unable to correct problems, you have held broken packages.\n", "stderr_lines": ["E: Unable to correct problems, you have held broken packages."], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nSome packages could not be installed. This may mean that you have\nrequested an impossible situation or if you are using the unstable\ndistribution that some required packages have not yet been created\nor been moved out of Incoming.\nThe following information may help to resolve the situation:\n\nThe following packages have unmet dependencies:\n openjdk-17-jre-headless : Depends: ca-certificates-java (>= 20190405~) but it is not installable\n                           Depends: java-common (>= 0.28) but it is not installable\n                           Depends: liblcms2-2 (>= 2.2+git20110628) but it is not installable\n                           Depends: libjpeg8 (>= 8c) but it is not installable\n                           Depends: libfontconfig1 but it is not installable\n                           Depends: libharfbuzz0b (>= 1.2.6) but it is not installable\n                           Depends: libpcsclite1 (>= 1.3.0) but it is not installable\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "Some packages could not be installed. This may mean that you have", "requested an impossible situation or if you are using the unstable", "distribution that some required packages have not yet been created", "or been moved out of Incoming.", "The following information may help to resolve the situation:", "", "The following packages have unmet dependencies:", " openjdk-17-jre-headless : Depends: ca-certificates-java (>= 20190405~) but it is not installable", "                           Depends: java-common (>= 0.28) but it is not installable", "                           Depends: liblcms2-2 (>= 2.2+git20110628) but it is not installable", "                           Depends: libjpeg8 (>= 8c) but it is not installable", "                           Depends: libfontconfig1 but it is not installable", "                           Depends: libharfbuzz0b (>= 1.2.6) but it is not installable", "                           Depends: libpcsclite1 (>= 1.3.0) but it is not installable"]}

I would understand if it always fails, but why just sometimes?我会理解它是否总是失败,但为什么有时会失败?

This doesn't look like an Ansible problem, since Ansible simply invokes apt on the system.这看起来不像 Ansible 问题,因为 Ansible 只是在系统上调用 apt。 This situation would also occur when you would execute the same action on the same system, at that time.当您当时在同一系统上执行相同操作时,也会发生这种情况。

When looking at the error:查看错误时:

you have held broken packages

You can google around yourself and look for a fitting solution.您可以自己搜索并寻找合适的解决方案。 When I read further, the error describes:当我进一步阅读时,错误描述为:

Building dependency tree...
Reading state information...
Some packages could not be installed. 
This may mean that you have requested an impossible situation 
or if you are using the unstable distribution that some 
required packages have not yet been created or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
openjdk-17-jre-headless : Depends: ca-certificates-java (>= 20190405~) but it is not installable

I would understand if it always fails, but why just sometimes?我会理解它是否总是失败,但为什么有时会失败?

It could mean that your previous task, which updates the system, causes a collision with updating other packages due to dependencies.这可能意味着您之前更新系统的任务由于依赖关系而导致与更新其他包发生冲突。

Why it would fail sometimes is unclear to us.为什么它有时会失败,我们不清楚。 Does it fail on a single system?它会在单个系统上失败吗? How often does it fail?它多久失败一次? Did it fail only after Ansible has run?只有在 Ansible 运行后才失败吗?

What you could do is edit your playbook to first verify whether 'apt-get update' works as it should, without any errors/complaints.你可以做的是编辑你的剧本,首先验证“apt-get update”是否正常工作,没有任何错误/投诉。 Once that is the case, proceed to the next task.一旦出现这种情况,请继续执行下一个任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM