Ansible:'shell'notexecuting
            
            
            
                
                
                     
                    创始人
                    
                
                
                
                     
                    2024-11-05 20:00:15
                
                
                     
                    0次
                    
                
                
             
            
            
            
                
                
- 
确认远程主机已安装bash或兼容shell。 
- 
设置ansible.cfg文件中的“executable = /bin/bash”(或适合您环境的shell)。 
- 
确保在命令中使用双引号(而非单引号)来包围任何参数和变量。 
例如:
- name: Run shell command
shell: "echo {{ variable }}"
become: true
- 确保使用适当的转义字符,例如“{{ '{{' }}”通过{{ '{{' }},或通过“{% raw %}{%{% endraw %}”在代码块中使用。
例如:
- name: Run shell command with escape characters
shell: "echo '{{ '{{' }} variable }}'"
become: true
 
            
            
                
                            
            
            
            
                
                
相关内容