我有以下内容:
const fs = require("fs");
const chartExporter = require('highcharts-export-server');
chartExporter.initPool();
const chartDetails = {
type: "png",
constr : 'ganttChart',
options: {
series: [{
data: [{
start: 1,
end: 10
}]
}]
}
};
chartExporter.export(chartDetails, (err, res) => {
// Get the image data (base64)
let imageb64 = res.data;
// Filename of the output
let outputFile = "bar.png";
// Save the image to file
fs.writeFileSync(outputFile, imageb64, "base64", function(err) {
if (err) console.log(err);
});
console.log("Saved image!");
chartExporter.killPool();
});
运行此命令(使用Rundeck),当调用救援进行回滚时,即使强制失败,我们也获得了成功。
- block:
- name: "actions"
... # some tasks
rescue:
- name: "Rollback"
... # some tasks
- name: "force fail after rollback"
debug:
msg: "this task is just to force a fail"
failed_when: true #tried yes instead of true too
紧跟documentation之后:
这将“还原”运行任务的失败状态,并且播放将如同成功一样继续进行。
我该如何在救援区中强制失败/使比赛失败?
Anisble版本:
PLAY RECAP *********************************************************************
Host1 : ok=99 changed=41 unreachable=0 failed=1
localhost : ok=3 changed=0 unreachable=0 failed=0
Host2 : ok=99 changed=41 unreachable=0 failed=1
Playbook finished: Fri Feb 7 17:16:16 2020, 211 total tasks. 0:04:04 elapsed.
答案 0 :(得分:1)
Q:“ Ansible块救援部队失败,失败时失败”
A:它与Ansible 2.9.4一样工作。下面的游戏
- hosts: localhost
tasks:
- block:
- debug:
msg: Block failed
failed_when: true
rescue:
- debug:
msg: Rescue started
- debug:
msg: Rescue failed
failed_when: true
给予
PLAY [localhost] ***
TASK [debug] ***
fatal: [localhost]: FAILED! => {
"msg": "Block failed"
}
TASK [debug] ***
ok: [localhost] => {
"msg": "Rescue started"
}
TASK [debug] ***
fatal: [localhost]: FAILED! => {
"msg": "Rescue failed"
}
PLAY RECAP ***
localhost: ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=1 ignored=0
$ ansible --version
ansible 2.9.4
config file = /home/tester/.ansible.cfg
configured module search path = [u'/home/tester/.ansible/my_modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.16 (default, Oct 7 2019, 17:36:04) [GCC 8.3.0]