我有一个需要unichar参数的函数.但是找不到一个很好的方法来初始化swift中的unichar.
我使用以下方式:
var delimitedBy:unichar = ("," as NSString).characterAtIndex(0)
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来初始化swift中的unichar?
我正在进行REST调用,并希望在继续之前检查我的请求是否已完成.在回复中,我得到了一个"PENDING"或"IN_PROGRESS"作为request_status.我想要等到"完成"或"失败".为了这个目的,我想等待"PENDING"或"IN_PROGRESS"
我尝试了很多变化但是没有成功,最后的尝试如下:
- name: Wait for the cluster deployment (this will take a while)
uri:
url: http://localhost:8080/api/v1/clusters/{{ cluster_name }}/requests/1
method: GET
user: admin
password: admin
HEADER_X-Requested-By: Ansible
force_basic_auth: yes
status_code: 200, 201, 202
return_content: yes
register: response
until: "'{{ (response.content | from_json).Requests.request_status }}' != 'PENDING' AND '{{ (response.content | from_json).Requests.request_status }}' != 'IN_PROGRESS'"
retries: 3
delay: 5
Run Code Online (Sandbox Code Playgroud)
错误是:
"条件检查''{{(response.content | from_json).Requests.request_status}}'!='PENDING'和'{{(response.content | from_json).Requests.request_status}}'!='IN_PROGRESS' '失败.错误是:模板错误,模板字符串:期望令牌'结束语句块',得到'AND'.字符串:{%if'COMPLETED'!='PENDING'和'COMPLETED'!='IN_PROGRESS'% }真{%else%} False {%endif%}"
所以,我的问题是如何在Ansible的do-until循环中指定多个条件?
我有一个可执行文件,可以说/ tmp / foo
我想尝试运行此二进制文件(最多5次),直到在日志文件中看到一行:可以说/tmp/start.log
我需要这样的戏剧:
- block:
- shell: /tmp/foo
- pause: seconds=30
- name: Check if started successfully
shell: grep 'started successfully' /tmp/start.log
register: grep
retry: 5
until: grep.stdout
Run Code Online (Sandbox Code Playgroud)
但是不幸的是Ansible块不支持retry-until。
我该如何实现?
我们正在使用ansible将多个节点配置为一个集群。这些机器是在自定义AWS类似基础设施上创建的实例。我们在不同的剧本上有大约一百个任务,它们在每个节点上执行。
问题是,我们收到零星的主机无法访问的错误,并且由于以下失败而停止了剧本的执行:
TASK [common : install basic packages] *************************
fatal: [fqdn.for.a.node]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh.", "unreachable": true}
Run Code Online (Sandbox Code Playgroud)
用-vvv输出:
TASK [common : install basic packages] *******************************
task path: /jenkins/workspace/Cluster-Deployment/91/roles/common/tasks/install-basic-packages.yml:1
<fqdn.for.a.node> ESTABLISH SSH CONNECTION FOR USER: root
<fqdn.for.a.node> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=600 -o ControlPath=/home/turkenh/.ansible/cp/ansible-ssh-%h-%p-%r fqdn.for.a.node '/bin/sh -c '"'"'( umask 77 && mkdir -p "` …Run Code Online (Sandbox Code Playgroud) openssh amazon-web-services ansible ansible-playbook ansible-2.x