RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题

问题[ansible]

Martin Hope
Clark Devlin
Asked: 2024-09-30 16:13:04 +0000 UTC

如何修复上传文件时出现ansible错误?

  • 6

我正在尝试使用 ansible 通过copy.我收到一个错误

UNREACHABLE! => {"changed": false, "msg": "Data could not be sent to remote host \"x.x.x.x\". Make sure this host can be reached over ssh.

所有主机都可以通过 ssh 访问,我可以从这台机器连接到它们。 ansible 的 ping 模块不会产生错误。我尝试ansible.cfg添加行,但结果是一样的。

transfer_method = smart
scp_if_ssh = smart

UPD,手动运行命令scp,发现在一定数量的文件后,下载速度下降,很快连接就断开了,与ansible同样的情况,通过减少文件数量,一切都加载得很好。

ansible
  • 1 个回答
  • 19 Views
Martin Hope
Ruin
Asked: 2024-02-02 23:49:29 +0000 UTC

Ansible 创建带有密码的用户

  • 6

大家下午好,我开始学习 Ansible 所以请不要过多评判剧本的质量。问题是,当你指向一行中的直接行时,会创建一个带有密码的用户,然后我可以通过ssh登录。但如果我通过变量传递密码,那就这样了,我无法通过 ssh 登录,就像没有设置密码一样。我尝试了两种方法(如代码所示),但除了直接传输之外,它们都不起作用。告诉我你如何解决这个问题?依赖那里所述的文档

If provided, set the user’s password to the provided encrypted hash (Linux) or plain text password (macOS).

这是剧本的一部分

  vars:
    username: ayu21
    password_user : 123qwe!@#
  

  tasks:
  - name: Get name if debian family when create user
    ansible.builtin.user: 
      user: "{{ username }}"
      password : "{{ '123qwe!@#' | password_hash('sha512') }}"
      # password: '{{ password_user }}'
      home: /home/"{{ username }}"
      shell: /bin/bash
      groups: sudo
      generate_ssh_key: yes
      ssh_key_bits: 2048
      ssh_key_file: .ssh/"{{ username }}"
    when: ansible_facts['os_family'] == "Debian"
ansible
  • 1 个回答
  • 28 Views
Martin Hope
ar rr
Asked: 2023-08-08 14:51:48 +0000 UTC

Ansible 如何使用对象列表

  • 6

有一个ansible剧本。我想修改它以满足我的需要。问题是这样的。我想根据剧本数据在系统中设置自己的字段。我在那里输入数据,如下所示:

- name: dicts
  hosts: all
 
  list_items: 
    - {item1: "aaa", item2: "bbb"}
    - {item1: "ccc", item2: "ddd"}
  
  tasks:
    - name: Start Program
      command: "./my_app.py {{ item.item1 }} {{ item.item2 }}"
      with_items: {{ list_items }}


在这种形式中,Playbook 抱怨设置 list_items 列表。错误 未找到预期的指示符“-”。从逻辑上讲,似乎不需要这个连字符。如何纠正这样的剧本以使其正确阅读?

UPD。还有另一种错误:

with_items:
  - {{ foo }}
Should be written as 
with_items:
  - "{{ foo }}"

此修复让我回到第一个错误

更新:对评论的疑问 - 这样的配置会起作用吗?

- name: dicts
  hosts: all

  vars:
    list_items:
      - { item1: aaa, item2: bbb }
      - { item1: ccc, item2: ddd }

  tasks:

    - name: Start Program
      command: "./my_app.py {{ item.item1 }} {{ item.item2 }}"
      with_items: "{{ list_items }}"

ansible
  • 1 个回答
  • 25 Views
Martin Hope
don Rumata
Asked: 2022-07-21 19:38:36 +0000 UTC

如何将 2 个列表转换为 Ansible 中的字典?

  • 0

有2个变量:

test2_dom_array:
  - example.com
  - example.org
test2_ip_array:
  - 127.0.0.1
  - 127.0.0.10

我该如何使用ansible:

[
  {
    "site": "example.com",
    "ip": "127.0.0.1"
  },
  {
    "site": "example.org",
    "ip": "127.0.0.10"
  }
]

我只得到:

block:
  - set_fact:
      dig_fact: []
  - set_fact: 
      dig_fact: "{{ dig_fact + [{ 'site': item.0 },{ 'ip': item.1 }] }}"

带排气:

[
  {
    "site": "example.com"
  },
  {
    "ip": "127.0.0.1"
  },
  {
    "site": "example.org"
  },
  {
    "ip": "127.0.0.10"
  }
]
администрирование ansible
  • 1 个回答
  • 52 Views
Martin Hope
Arch Cat
Asked: 2022-07-13 00:24:01 +0000 UTC

Ansible,jinja2

  • 0

告诉我,我无法理解。为了测试,我赶紧勾勒,体验0..j2文件:

{% for group in groups['all'] %}
Host {{ group }}
User {{ ansible_user }}
{% endfor %}

主机文件:

[test1]
localhost1 ansible_host=localhost ansible_host_ip=127.0.0.1 ansible_user=arch1 ansible_connection=local
localhost2 ansible_host=localhost ansible_host_ip=127.0.0.2 ansible_user=test ansible_connection=local
localhost3 ansible_host=localhost ansible_host_ip=127.0.0.3 ansible_user=test ansible_connection=local
[test2]
localhost4 ansible_host=localhost ansible_host_ip=127.0.0.4 ansible_user=root1 ansible_connection=local

.yml 文件:

---
- name: Test SSH create
  hosts: all
  tasks:
    - name: Update Test SSH Jinja2
      template:
        src: /etc/ansible/temlates/ssh_test.j2
        dest: /etc/ansible/test

并输出:

Host localhost1
User test
Host localhost2
User test
Host localhost3
User test
Host localhost4
User test

为什么 ansible_user 总是一样的?他为什么不把它们一一放下?据我了解,这是因为 ansible_user 变量取自创建配置的主机。如何在不使用模块的情况下解决此问题?

ansible
  • 1 个回答
  • 25 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5