以下是库存内容:
return
这是剧本的内容:
[osm]
osm_host ansible_port=22 ansible_host=10.20.20.11 ansible_user=ubuntu ansible_ssh_private_key_file=/path/to/key/key
运行- hosts: osm
user: ubuntu
become: yes
tasks:
- name: Download the OSM installer
get_url: url=https://osm-download.etsi.org/ftp/osm-8.0-eight/install_osm.sh dest=/tmp/install_osm.sh
- name: Execute the OSM installer
shell: /tmp/install_osm.sh
时,出现以下错误:
播放[osm]
任务[聚会事实] ****************************************************** *******好的:[osm_host]
任务[下载OSM安装程序] **************************************************好的:[osm_host ]
任务[执行OSM安装程序] ***************************************************致命:[ osm_host]:失败! => {“更改”:true,“ cmd”:“ / tmp / install_osm.sh”,“增量”: “ 0:00:00.001919”,“结束”:“ 2020-09-04 19:26:46.510381”,“ msg”: “非零返回码”,“ rc”:126,“开始”:“ 2020-09-04” 19:26:46.508462“,” stderr“:” / bin / sh:1:/tmp/install_osm.sh: 权限被拒绝“,” stderr_lines“:[” / bin / sh:1:/tmp/install_osm.sh: 权限被拒绝“],” stdout“:”“,” stdout_lines“:[]}
PLAY RECAP ****************************************************** ******************* osm_host:ok = 2已更改= 0不可达= 0
失败= 1跳过= 0救援= 0忽略= 0
我尝试对ansible-playbook -i inventory play.yaml
子句使用true
和yes
,但没有任何变化。我想念什么?
答案 0 :(得分:1)
您必须确保root用户对新的OSM下载具有可执行权限。当您使用 become:是而不使用 become_user 时,默认用户为 root 因此,您需要确保root用户可以执行您的脚本。
尝试这样的get_url:
- hosts: osm
user: ubuntu
become: yes
tasks:
- name: Download the OSM installer
get_url:
url: https://osm-download.etsi.org/ftp/osm-8.0-eight/install_osm.sh
dest: /tmp/install_osm.sh
mode: "0555"
- name: Execute the OSM installer
shell: /tmp/install_osm.sh
使用 get_url 模块的模式参数进行播放。