vars:
alias_name: '{{ alias }}'
upload_file: '{{ upload }}'
pack1: /home/ansible
tasks:
- name: Copy file with owner and permissions
copy:
src: '{{ upload_file }}'
dest: '{{ pack1 }}'
owner: ansible
group: ansible
mode: '0777'
- name: return motd to registered var
command: "ls -Art | tail -n 1"
args:
chdir: '{{ pack1 }}'
register: mymotd
- name: Import SSL certificate from google.com to a given cacerts keystore
java_cert:
cert_path: '{{ pack1 }}/{{ mymotd.stdout }}'
cert_alias: '{{ alias_name }}'
keystore_path: '/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64/jre/lib/security/cacerts'
keystore_pass: changeit
state: present
错误:
失败! => {“已更改”:错误,“调用”:{“ module_args”:{“ _raw_params”:“ ls -Art | tail -n 1”,“ chdir”:“ / home / ansible”,“ register”:“ mymotd”,“警告”:为true}},“ msg”:“(命令)模块的不受支持的参数:寄存器受支持的参数包括:_raw_params,_uses_shell,argv,chdir,创建,可执行,删除,stdin,stdin_add_newline,strip_empty_ends,警告”}
PLAY RECAP ********************************************** ****************************************************** ***************************************172.16.217.129:ok=2更改= 0不可达= 0失败= 1跳过= 0获救= 0忽略= 0 =>
还有其他方法可以建议我做同样的事情,所以请告诉我,我的主要目的是将命令输出传递给变量,并稍后使用该变量附加到证书路径中
我的Ansible剧本。主机:所有变量:alias_name:'{{alias}}'upload_file:'{{upload}}'pack1:/ home / ansible任务:-name:复制具有所有者和权限的文件copy:...
return motd to registered var
的缩进。另外,Ansible剧本使用YAML格式,因此请按照正确的YAML format对其进行格式化。