AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[ansible-tower](server)

Martin Hope
davidburtton
Asked: 2021-09-23 07:42:11 +0800 CST

将“ansible_failed_result”变量传递给 Tower Notification

  • 1

我正在尝试找到一种方法来分别使用本机 Ansible 和 Tower 故障变量和通知来发送包含作业执行输出结果的电子邮件。

所以我有一个这样的剧本:

  rescue:
    - debug:
        msg: "Failure:\n\n{{ansible_failed_result | to_nice_json}}"

这给了我一个很好的输出塔

但是,我还希望能够将相同的输出从 Tower 传递到电子邮件通知,这样我就可以在电子邮件中看到作业的输出,而无需登录到 Tower。这意味着我可以立即从我的电子邮件中知道是连接超时还是更严重的问题。

我已经尝试在 Tower 中使用自定义通知并尝试了“job.job_explanation”字段,但是它总是返回空。

我尝试以更详细的方式运行这项工作,但这也不起作用。

关于如何做到这一点的任何想法?在这一点上,我不确定我是否在使用 job_explanation 字段的正确轨道上,所以任何帮助将不胜感激!

谢谢

ansible ansible-tower
  • 1 个回答
  • 321 Views
Martin Hope
mitchell2423
Asked: 2021-08-16 19:55:44 +0800 CST

使用 ansible tower 加载其他模块

  • 0

我正在尝试在 ansible Tower 上运行剧本,但在加载额外模块时遇到问题。我检查了剧本的配置是否正确,但仍然失败并显示以下消息...

[WARNING]: Invalid characters were found in group names but not replaced, use
-vvvv to see details
ERROR! couldn't resolve module/action 'ansible.windows.win_package'. This often indicates a misspelling, missing collection, or incorrect module path.
The error appears to be in '/tmp/bwrap_371_vfy0csh9/awx_371_vu6g6dfa/project/windows-playbook.yml': line 5, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
    - name: Test Install
      ^ here

我可能是盲人,但我如何让 ansible tower 加载这些模块?我不确定它是我错过的设置还是剧本本身需要额外的配置......任何帮助将不胜感激。我将在下面弹出我的剧本。

---
- hosts: all

  tasks:
    - name: Test Install
      ansible.windows.win_package:
        path: \\FILESHARE\data\Software\Installer.msi
        arguments: '/q /norestart'
        state: present
ansible ansible-playbook ansible-tower
  • 1 个回答
  • 325 Views
Martin Hope
MacMartin
Asked: 2021-05-18 02:04:39 +0800 CST

如何增加25的awx cli结果限制

  • 0

我在拥有超过 100 台服务器的环境中使用 awx cli (19.1.0) 和 awx (13.0.0)

当(例如)查询失败或更改结果时:

awx --conf.host https://my.awx --conf.username myuser --conf.password mypass -k -f human --filter 'event_display,event_data,host_name,play,task,stdout' job_events list --job 1234 --event runner_on_ok --changed true > /tmp/tmp

我只得到 25 个结果。
(这适合 awx api 的分页吗?!)
是否可以选择获取 awx 运行的每个结果?
(ARA将是 cli 的绝佳替代品,但不适用于我的环境/任务)


更新/提示--help我不知道如果成功通过身份验证 ,似乎只能获得正确的命令行帮助( )(请参阅我对答案的评论)

ansible ansible-tower
  • 1 个回答
  • 316 Views
Martin Hope
user597296
Asked: 2020-10-20 13:53:48 +0800 CST

是否可以将数据从一个 Ansible Tower 复制到另一个?

  • 2

我正在尝试将所有数据(模板、凭据、库存等)从我的 Ansible Tower 生产实例复制到我新创建的开发实例。有没有办法使用 ansible API 自动执行此操作?我试图研究tower-cli但似乎没有太多关于这个用例的信息。此外, tower-cli 似乎已被弃用。

ansible ansible-tower
  • 1 个回答
  • 1713 Views
Martin Hope
utcruibvdjrtijiiue
Asked: 2020-09-10 06:07:09 +0800 CST

每个人如何使用 ansible 管理多服务器环境及其凭据?

  • 0

我试图找出在 AWX/Tower/Ansible 中管理多服务器 (linux) 环境的最干净和/或最安全的方法。

我已经看过一些关于这个主题的帖子,但似乎没有一个明确的答案来说明哪种方法最安全。

假设我想针对 20 个不同的 linux 服务器使用单个模板/剧本,所有服务器都具有不同的用户和密码/sudo 密码。

我可以想到几个选项;

在每个主机上创建一个专用的“ansible”用户,AWX 服务器或本地服务器具有私钥信息。我认为这在大多数情况下都可以,但是如果尝试执行需要 root 的操作,那么 sudo 密码就会出现问题,除非“ansible”用户在每台服务器上都有相同的密码。可以设置为拥有 NOPASSWD sudo 访问权限,但这感觉不对。

保持每个主机具有不同用户和密码组合的当前情况,但可能在加密(保险库)vars 文件中指定凭据。

每个主机都有一个单独的模板,每个主机都具有该主机的正确机器凭据集。这也让人感觉有点不对劲,而且非常麻烦/难以维护。

请让我是否遗漏了一些明显的东西。

ansible ssh-keys ansible-tower
  • 1 个回答
  • 376 Views
Martin Hope
saffron
Asked: 2020-08-17 11:15:42 +0800 CST

在 Ansible Playbook 中将字符串转换为整数

  • 9

我从 powershell 命令中获取计数并将其注册到变量上。我必须在条件下使用该计数。在 when 条件下使用它之前,我已将其更改为 int 。尽管此处的计数为 0,但仍会跳过该任务(邮件通知)。有人可以告诉我我在这里做错了什么。下面是我正在执行的代码

      - name: Get message_count
        shell:  echo "{{ (output.stdout | from_json).MessageCount  }}"
        register: message_count   #message_count is Zero here
        delegate_to: localhost
     
      - set_fact:
          countt: "{{ message_count | int}}"    

#在使用 set_fact 传递给条件之前尝试转换为整数

      - debug: var=countt
      - name: send mail notification
        mail:
           host: abc.zzzz.net
           port: 25
           from: <[email protected]>
           to:
           - [email protected]        

           subject: Test mail sent from core server 
           body: Test mail sent from core server        
        delegate_to: localhost
        when: countt==0
ansible ansible-playbook ansible-tower
  • 1 个回答
  • 29964 Views
Martin Hope
saffron
Asked: 2020-07-29 06:26:16 +0800 CST

如何在 Ansible 中将 array_name 动态分配给 with_items

  • 1

我有一个 json 文件(server.json),其内容如下:

   servers_groupA: [{server_name: server1abc.net, start_file: w.bat, stop_file: d.bat},
           
          {server_name: server2.abc.net, start_file: w.bat, stop_file: d.bat}
          ]
    servers_groupB: [{server_name: server3.abc.net, start_file: e.bat, stop_file: f.bat},
           
          {server_name: server4.abc.net, start_file: e.bat, stop_file: f.bat }
          ]

我必须使用以下代码将此服务器动态分配给一个组:

           hosts: localhost
           gather_facts: false
           ignore_errors: yes
           vars:
             server_vaar: "servers_groupA"
             #server_vaar: {{ server_group }}
       
       
    tasks:
          
          - name: Importing json file
            include_vars: 
              file: server.json
            
              
          - name: Adding host dynamically to inventory
            add_host:
              hostname: "{{ item.server_name }}"
              groups: testing_servers_group
              ansible_connection: winrm
              ansible_port: 5985
              ansible_winrm_transport: ntlm
              ansible_winrm_scheme: http  
              ansible_winrm_server_cert_validation: ignore
              ansible_winrm_operation_timeout_sec: 60
              ansible_winrm_read_timeout_sec: 70           
            with_items: "{{ server_vaar }}"

因此,vars 中提到的 server_vaar 的值将作为额外变量从 Splunk 传递给脚本,或者在 ansible 脚本运行时手动传递。

此 server_vaar 值可以是 servers_groupA、servers_groupB、servers_groupC、servers_groupD。我们需要将此名称传递给“动态添加主机到库存”任务中的 with_items。这样它就会进入 json 文件中的那个数组,并将 server_name 从该列表传递到库存,并创建一个组“testing_servers_group”作为库存组。

所以我传入了 with_items: "{{ server_vaar}}" 这应该被视为 with_items: "{{ servers_groupA }}"

但它为该 server_vaar 抛出了错误作为“未定义的变量”。我找不到将此组名传递给 with 项目的解决方案。谁能给我一些关于我面临的这个问题的想法。

scripting shell ansible ansible-playbook ansible-tower
  • 1 个回答
  • 913 Views
Martin Hope
rawmain
Asked: 2020-05-02 18:13:22 +0800 CST

如何在没有 Docker 的 RHEL 7 上安装 AWX?

  • 1

当我按照本指南在没有 docker 的 RHEL 上安装 AWX 时:http: //yallalabs.com/devops/how-to-install-ansible-awx-without-docker-centos-7-rhel-7/

https://copr.fedorainfracloud.org/coprs/mrmeee/awx/repo/epel-7/mrmeee-awx-epel-7.repo已重命名。然后我得到了这个:https ://copr.fedorainfracloud.org/coprs/mrmeee/ansible-awx/repo/epel-7/mrmeee-ansible-awx-epel-7.repo ,下载并设置为/etc/yum.repos.d/awx-rpm.repo.

我运行这个命令来安装它

yum install -y ansible-awx

出错了Requires: rh-python36-runtime。

...
Error: Package: rh-python36-social-auth-app-django-3.1.0-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-python(abi) = 3.6
Error: Package: rh-python36-oauthlib-3.1.0-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-runtime
Error: Package: ansible-awx-9.1.1.211-1.el7.x86_64 (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-postgresql10-postgresql-devel
Error: Package: rh-python36-ansible-runner-1.4.4-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-python(abi) = 3.6
Error: Package: rh-python36-websocket_client-0.57.0-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: /opt/rh/rh-python36/root/usr/bin/python3
Error: Package: rh-python36-django-oauth-toolkit-1.1.3-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-runtime
Error: Package: ansible-awx-9.1.1.211-1.el7.x86_64 (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-idna
Error: Package: rh-python36-kombu-4.6.7-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-runtime
Error: Package: rh-python36-django-jsonfield-1.2.0-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-python(abi) = 3.6
Error: Package: rh-python36-django-polymorphic-2.1.2-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-runtime
Error: Package: ansible-awx-9.1.1.211-1.el7.x86_64 (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-python-logstash
Error: Package: rh-python36-jaraco.functools-3.0.0-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-python(abi) = 3.6
Error: Package: rh-python36-twilio-6.35.1-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-python(abi) = 3.6
Error: Package: rh-python36-django-auth-ldap-2.1.0-1.noarch (copr:copr.fedorainfracloud.org:nsdc92:ansible-awx)
           Requires: rh-python36-python(abi) = 3.6
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

我试图安装rh-python36

# yum install rh-python36
Loaded plugins: search-disabled-repos
No package rh-python36 available.

运行subscription-manager命令准备安装rh-python36时,出现错误

# subscription-manager repos --enable rhel-server-rhscl-7-rpms
Traceback (most recent call last):
  File "/sbin/subscription-manager", line 9, in <module>
    load_entry_point('subscription-manager==1.21.10', 'console_scripts', 'subscription-manager')()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/scripts/subscription_manager.py", line 85, in main
    return managercli.ManagerCLI().main()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/managercli.py", line 2667, in main
    ret = CLI.main(self)
  File "/usr/lib64/python2.7/site-packages/subscription_manager/cli.py", line 183, in main
    return cmd.main()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/managercli.py", line 467, in main
    self.cp = self.cp_provider.get_consumer_auth_cp()
  File "/usr/lib64/python2.7/site-packages/subscription_manager/cp_provider.py", line 110, in get_consumer_auth_cp
    restlib_class=self.restlib_class)
  File "/usr/lib64/python2.7/site-packages/rhsm/connection.py", line 783, in __init__
    info = utils.get_env_proxy_info()
  File "/usr/lib64/python2.7/site-packages/rhsm/utils.py", line 224, in get_env_proxy_info
    info = parse_url(proxy_info, default_port=DEFAULT_PROXY_PORT)
  File "/usr/lib64/python2.7/site-packages/rhsm/utils.py", line 200, in parse_url
    raise ServerUrlParseErrorPort(local_server_entry)
rhsm.utils.ServerUrlParseErrorPort

参考:https ://access.redhat.com/solutions/1519803

yum rhel7 ansible-tower
  • 1 个回答
  • 4944 Views
Martin Hope
saffron
Asked: 2020-04-21 21:29:09 +0800 CST

如何将带有特殊字符的密码从ansible发送到Python脚本?

  • 0

我正在从 ansible playbook 调用 python 脚本。在调用时,我将凭据作为参数传递给 python 脚本。密码有一些特殊字符。

但是在 Python 脚本中,我收到的密码没有特殊字符。所以密码不正确,我收到未经授权的错误。

我在 Ansible 塔中拥有此证书。所以我将 ansible playbook 和 python 脚本都保存在 Git 中,并在 Ansible Tower 中作为作业运行。

- hosts: localhost
  gather_facts: false
 vars:
  username: '{{ lookup("env","CREDS_TEST_PWD_USERNAME") }}'
  password: '{{ lookup("env","CREDS_TEST_PWD_PASSWORD") }}'
 tasks:

  - debug: var=password
  - name: Invoking python script
    script: python_script.py {{username}} {{password}}
    args:
      executable: python
    register: user_response
    delegate_to: perbhd01

  - debug: var=user_response 

以上是调用 python 脚本的 Ansible 剧本。假设实际的用户名和密码是“ADMIN”和“Oracle$123!”。但是我在 Python 脚本中得到的是“ADMIN”和“Oracle123!”

这就是我在 python 脚本中检索凭据的方式。

 import requests
 import json
 import warnings
 import sys
 user_name=sys.argv[1]
 password=sys.argv[2]
 print (password +"****from ansible****")

如果您对我面临的这个问题有任何想法,请告诉我。

python ansible ansible-playbook ansible-tower
  • 1 个回答
  • 3355 Views
Martin Hope
saffron
Asked: 2020-04-17 01:57:12 +0800 CST

通过 Ansible Playbook 调用 Python 脚本并在后台运行 - 通过 Ansible Tower

  • 0

在这里,我试图通过 ansible playbook 调用 python 脚本。当我运行包含下面提到的代码的剧本时,它成功地调用了脚本。但是 ansible 脚本会继续运行,直到 Python 脚本完成其所有任务。

- hosts: localhost
  gather_facts: false
  vars:
    username: 'User'
    password: '1234@345'
  tasks:

    - name: Invoking Python script
      script: data_pull_push.py 
      args:
        executable: python

python 脚本“data_pull_push.py”正在从一个 Url 获取数据并将其发布到另一个 Url。它的数据太多了。因此,检索和发布所有数据需要很长时间。所以我希望 Ansible 剧本触发其中的 Python 脚本并关闭剧本。Python 脚本应该在后台运行。

这个 Ansible playbook 和 python 脚本保存在 git 中,并将在 Ansible tower 中运行 playbook。我不知道如何在 Ansible 中使用它。如果有人知道请告诉我。

python ansible ansible-playbook ansible-tower
  • 2 个回答
  • 3891 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve