Ansible yaml代码中的错误无法找到预期的';:';
yaml代码Ansible yaml代码中的错误无法找到预期的';:';,ansible,Ansible,yaml代码 -主机:所有 任务: #导入Remi GPG密钥-请参阅:http://rpms.famillecollet.com/RPM-GPG-KEY-remi wgethttp://rpms.famillecollet.com/RPM-GPG-KEY-remi \-O/etc/pki/rpm gpg/rpm gpg密钥remi rpm—导入/etc/pki/rpm gpg/rpm gpg密钥remi #安装Remi-repo rpm-Uvh——安静\ http://rpms.famille
-主机:所有
任务:
#导入Remi GPG密钥-请参阅:http://rpms.famillecollet.com/RPM-GPG-KEY-remi
wgethttp://rpms.famillecollet.com/RPM-GPG-KEY-remi \-O/etc/pki/rpm gpg/rpm gpg密钥remi
rpm—导入/etc/pki/rpm gpg/rpm gpg密钥remi
#安装Remi-repo
rpm-Uvh——安静\
http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安装EPEL repo
yum install epel-release
安装Node.js(npm及其所有依赖项)
我在编译时遇到以下错误:错误!加载YAML时出现语法错误。
错误似乎出现在“/home/shahzad/playbook.yml”行中
7,第3列,但可能位于文件的其他位置,具体取决于
语法问题
令人不快的一行似乎是:
wget http://rpms.famillecollet.com/RPM-GPG-KEY-remi \ -O /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
^ here
异常类型:
例外情况:扫描简单键时
在“”中,第6行第3列
找不到预期的“:”
在“”中,第7行第3列
- 如果您希望在yaml剧本中使用shell命令,如
,则需要使用以下模块:wget
- “:”是yaml中的特殊字符,请阅读官方ansible文档中的,以便引用
- 对于yum命令,可以使用ansible的模块
作为一种最佳实践,您可以使用它来调试YAML语法,检查解析器失败的确切行和列。我安装了上述说明中的所有内容,但我使用安装程序
alien
在Ubuntu 18.04上转换和安装rpm包。
但是您将无法使用yum安装,因为某些软件包不在其列表中
使用外国人:
# apt install alien # apt install -y
# cd /tmp
# wget http://rpms.famillecollet.com/RPM-GPG-KEY-remi \ -O /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# alien -kiv remi-release-6.rpm
# ls -l
# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# alien epel-release-latest-8.noarch.rpm
# ls -l
# alien -k epel-release-latest-8.noarch.rpm ; alien -i epel-release-latest-8.noarch.rpm
# cd /home/user
# apt install curl gcc g++ make # apt install -y
# curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
# apt install nodejs # apt install -y
# curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# apt update ; sudo apt install yarn # apt install -y
# apt install nodejs ; apt upgrade ; passwd -dl root ; reboot # apt install -y
但我仍然有相同的错误无效YAML:找不到预期的“:”:
,但在命令networkctl
上,我更好地看到,它说失败了
(尽管在安装node.js、remi release、epel release之前,它没有这样签名)哪些接口配置不正确
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 ens11 ether off unmanaged
3 enp2t1 ether routable configured
4 br0 ether off failed
5 vlan5 ether off configuring
这些安装的软件包让你深入了解界面错误,这种方法很有效!!!!!!!!谢谢你的支持 你能把你的yaml代码寄出去吗?这似乎不是正确的yaml代码。
- name: Import Remi GPG key
shell: wget ...
# apt install alien # apt install -y
# cd /tmp
# wget http://rpms.famillecollet.com/RPM-GPG-KEY-remi \ -O /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# alien -kiv remi-release-6.rpm
# ls -l
# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# alien epel-release-latest-8.noarch.rpm
# ls -l
# alien -k epel-release-latest-8.noarch.rpm ; alien -i epel-release-latest-8.noarch.rpm
# cd /home/user
# apt install curl gcc g++ make # apt install -y
# curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
# apt install nodejs # apt install -y
# curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# apt update ; sudo apt install yarn # apt install -y
# apt install nodejs ; apt upgrade ; passwd -dl root ; reboot # apt install -y
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 ens11 ether off unmanaged
3 enp2t1 ether routable configured
4 br0 ether off failed
5 vlan5 ether off configuring