我正在尝试在Ubuntu 18.04上使用ansible(2.5.1)安装Java + jenkins。我扮演的角色:
- name: Add Jenkins apt repository key.
apt_key:
url: "https://pkg.jenkins.io/debian/jenkins.io.key"
state: present
- name: Add Jenkins apt repository.
apt_repository:
repo: "deb http://pkg.jenkins.io/debian-stable binary/"
state: present
update_cache: yes
- name: Install Jenkins
apt: name={{item}} state=latest
with_items:
- openjdk-8-jdk
- jenkins
它失败:
failed: [xxx.xx.xxx.xxx] (item=[u'openjdk-8-jdk', u'jenkins']) => {"cache_update_time": 1537989126, "cache_updated": false, "changed": false, "item": ["openjdk-8-jdk", "jenkins"], "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'openjdk-8-jdk' 'jenkins'' failed: E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "rc": 100, "stderr": "E: Sub-process /usr/bin/dpkg returned an error code (1)\n", "stderr_lines": ["E: Sub-process /usr/bin/dpkg returned an error code (1)"], "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following package was automatically installed and is no longer required:\n linux-modules-4.15.0-29-generic\nUse 'apt autoremove' to remove it.\nThe following additional packages will be installed:\n adwaita-icon-theme ca-certificates-java daemon dconf-gsettings-backend\n dconf-service fontconfig fontconfig-conf
....
/jvm/java-8-openjdk-amd64/jre/bin/policytool to provide /usr/bin/policytool (policytool) in auto mode", "Setting up openjdk-8-jdk:amd64 (8u181-b13-0ubuntu0.18.04.1) ...", "update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode", "update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode", "Processing triggers for libc-bin (2.27-3ubuntu1) ...", "Processing triggers for ureadahead (0.100.0-20) ...", "Processing triggers for systemd (237-3ubuntu10.3) ...", "Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.36.11-2) ...", "Errors were encountered while processing:", " jenkins"]}
如果我将安装分成两部分,则可以使用:
- name: Install Java
apt: name={{item}} state=latest
with_items:
- openjdk-8-jdk
- name: Install Jenkins
apt: name={{item}} state=latest
with_items:
- jenkins
有什么想法吗?如果使用with_items
可以有一些比赛条件吗?