标签: ansible

无法将多行字符串(私有 ssh 密钥)存储为 ansible 中的变量

我正在尝试将ssh私钥存储为ansible变量。

它位于加密文件中,或多或少像这样

my_private_key: |
-----BEGIN OPENSSH PRIVATE KEY-----

kd02ke0ke0k20ke0ke40430940943090494
[...]

Xekrfmfimimfimfeimiefmim4304309430943==

-----END OPENSSH PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)

但是ansible执行失败,如下:

ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
  could not find expected ':'

The error appears to be in '/Users/pantelis/path/to/my/encrypted/file': line 6, column 1, but may
be elsewhere in the file depending on …
Run Code Online (Sandbox Code Playgroud)

ansible

-1
推荐指数
1
解决办法
816
查看次数

将 groovy 列表转换为 Yaml

我正在寻找在 groovy 中转换列表

array = ['hostname1','hostname2','hostname3']
Run Code Online (Sandbox Code Playgroud)

转换为 Ansible inventory Yaml 格式,类似于

---
all:
  hosts:
     hostname1:
     hostname2:
     hostname3:
       
Run Code Online (Sandbox Code Playgroud)

欢迎任何建议。

groovy yaml ansible ansible-inventory

-1
推荐指数
1
解决办法
273
查看次数

通过 Ansible playbook 安装 nodejs

我创建了一个 Vagrant vm (Ubuntu) 并安装了 Ansible。我可以 ping 我的本地主机,这意味着我的虚拟机。我写了一个剧本来安装 nodejs。

---
- hosts: node #it contains localhost
  gather_facts: no
  tasks:
  - name: install node.js
    shell: apt-get install nodejs
    sudo: yes
Run Code Online (Sandbox Code Playgroud)

当我运行剧本时,状态显示成功。据我了解,它应该在我的虚拟机中安装 nodejs 和 npm。但是,如果我输入node -v,则显示尚未安装。

vagrant@vagrant-ubuntu-trusty-64:/vagrant_data$ ansible-playbook ping.yml

PLAY [node] *******************************************************************

TASK: [install node.js] *******************************************************
changed: [localhost]

PLAY RECAP ********************************************************************
localhost                  : ok=1    changed=1    unreachable=0    failed=0

vagrant@vagrant-ubuntu-trusty-64:/vagrant_data$ node -v
The program 'node' can be found in the following packages:
 * node
 * nodejs-legacy
Ask your administrator to install one …
Run Code Online (Sandbox Code Playgroud)

ubuntu node.js ansible

-2
推荐指数
1
解决办法
3248
查看次数

ansible 在远程主机上运行 playbook

任何人都可以为我提供比下面更好的命令

rsync -e "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l $USER `cat commandResult` "ansible-playbook --connection=local /home/ec2-user/ansible/plays/install.yml"
Run Code Online (Sandbox Code Playgroud)

ansible

-5
推荐指数
1
解决办法
2万
查看次数

在Ansible中使用通配符进行批量复制

请注意,我试图使用ansible将批量文件从源服务器复制到目标服务器.在尝试错误时.请帮我.

---
- name: Going to copy bulk files
hosts: test
vars_prompt:
- name: copy
prompt: Enter the Bulk File to Copy
private: no
tasks:
- name: Copy bulk files
shell: cp /tmp/guru/{{ copy }}* /ansible/sri
Run Code Online (Sandbox Code Playgroud)

ansible

-6
推荐指数
1
解决办法
5387
查看次数

标签 统计

ansible ×5

ansible-inventory ×1

groovy ×1

node.js ×1

ubuntu ×1

yaml ×1