Ansible 由于权限被拒绝,Playbook无法执行
以下是库存内容:Ansible 由于权限被拒绝,Playbook无法执行,ansible,ansible-inventory,Ansible,Ansible Inventory,以下是库存内容: [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
[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
当我运行ansible playbook-I inventory play.yaml时,我得到以下错误:
播放[osm]
任务[收集事实]
*********************************************************确定:[osm_主机]
任务[下载OSM安装程序]
**********************************************确定:[osm_主机]
任务[执行OSM安装程序]
***********************************************致命:[osm\U主机]:失败!=>{“changed”:true,“cmd”:“/tmp/install_osm.sh”,“delta”:
“0:00:00.001919”,“结束”:“2020-09-04 19:26:46.510381”,“消息”:
“非零返回码”,“rc”:126,“开始”:“2020-09-04
19:26:46.508462,“标准”:“/bin/sh:1:/tmp/install_osm.sh:
“权限被拒绝”,“标准行”:[“/bin/sh:1:/tmp/install_osm.sh:
权限被拒绝“],“标准输出”:“,“标准输出行”:[]}
重演
*********************************************************************osm_主机:确定=2已更改=0无法访问=0
失败=1跳过=0解救=0忽略=0
我尝试使用true
和yes
作为been
子句,但没有任何更改。我缺少什么?您必须确保root用户具有新OSM下载的可执行权限。如果使用been:yes而不使用been\u用户,则默认用户为root
所以您需要确保root用户可以执行您的脚本
请尝试这样的获取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
使用获取url模块的模式参数进行播放。是。由于我是Ansible的新手,我只是忘记了应该设置要执行的文件权限。我想这应该是我的Ansible文件中的一个问题。=]非常感谢。顺便说一下,OSM脚本需要一个不同于root的用户,因此,我删除了been:yes
;)