[ansible-playbook]指定的行不再在文件中,也许它改变了?
[ansible-playbook]specified line no longer in file, maybe it changed?
我有一个 ansible-playbook,当我尝试 运行 这个 playbook 时,我收到了这个错误
(指定的行不再在文件中,也许它改变了?)
--
- name: check if the public/private key exist at ~/.ssh/
stat:
path: /root/.ssh/id_rsa.pub
register: st
- name: run the command
command: cat /root/.ssh/id_rsa.pub|ssh -i /root/.ssh/bi_ppc.pem ubuntu@"{{items}" "cat >> .ssh/authorized_keys"
with_items:
- groups['ubuntu']
when: st.changed
~
ansible --version
ansible 2.2.0.0
config file = /home/swathi/Desktop/infrastructure/ansible.cfg
configured module search path = Default w/o overrides
您可以使用 authorized_key
模块,将 pub 密钥从本地复制到远程。
--
- name: get public key
local_action: shell cat /home/user/.ssh/id_rsa.pub
register: pubkey
- name: check keys
debug: msg="{{ pubkey.stdout }}"
- name: add public key on the remote server
authorized_key: user=root key="{{ item[0] }}"
delegate_to: "{{ item[1] }}"
with_nested:
- "{{ pubkey.stdout }}"
- "{{groups['ubuntu']}}"
我遇到了来自 ansible 的相同错误消息:
$ ansible-playbook t.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
ERROR! Syntax Error while loading YAML.
found unexpected end of stream
The error appears to be in '/root/ansible/t.yml': line 6, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
(specified line no longer in file, maybe it changed?)
剧本是:
$ cat t.yml
---
- hosts: localhost
tasks:
- debug:
msg: "unterminated quoted string
实际上存在一个 YAML 语法错误,剧本末尾缺少双引号。当它完成剧本时,我的编辑器没有通过显示不同的颜色来帮助我。
希望对其他人有所帮助。
我有一个 ansible-playbook,当我尝试 运行 这个 playbook 时,我收到了这个错误 (指定的行不再在文件中,也许它改变了?)
--
- name: check if the public/private key exist at ~/.ssh/
stat:
path: /root/.ssh/id_rsa.pub
register: st
- name: run the command
command: cat /root/.ssh/id_rsa.pub|ssh -i /root/.ssh/bi_ppc.pem ubuntu@"{{items}" "cat >> .ssh/authorized_keys"
with_items:
- groups['ubuntu']
when: st.changed
~
ansible --version
ansible 2.2.0.0
config file = /home/swathi/Desktop/infrastructure/ansible.cfg
configured module search path = Default w/o overrides
您可以使用 authorized_key
模块,将 pub 密钥从本地复制到远程。
--
- name: get public key
local_action: shell cat /home/user/.ssh/id_rsa.pub
register: pubkey
- name: check keys
debug: msg="{{ pubkey.stdout }}"
- name: add public key on the remote server
authorized_key: user=root key="{{ item[0] }}"
delegate_to: "{{ item[1] }}"
with_nested:
- "{{ pubkey.stdout }}"
- "{{groups['ubuntu']}}"
我遇到了来自 ansible 的相同错误消息:
$ ansible-playbook t.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
ERROR! Syntax Error while loading YAML.
found unexpected end of stream
The error appears to be in '/root/ansible/t.yml': line 6, column 1, but may
be elsewhere in the file depending on the exact syntax problem.
(specified line no longer in file, maybe it changed?)
剧本是:
$ cat t.yml
---
- hosts: localhost
tasks:
- debug:
msg: "unterminated quoted string
实际上存在一个 YAML 语法错误,剧本末尾缺少双引号。当它完成剧本时,我的编辑器没有通过显示不同的颜色来帮助我。
希望对其他人有所帮助。