首页 > 其他分享 >【Ansible】ansible调用主机报错问题

【Ansible】ansible调用主机报错问题

时间:2024-09-02 16:52:32浏览次数:6  
标签:Ansible 192.168 hosts host ansible ip6 报错 eno16777984

ansible预计实现功能,自动生成/etc/hosts文件,copy到远程机器,出现如下错误:

配置如下:

    ---
    - hosts: 192.168.31.12
      remote_user: cluster
      sudo: yes
      tasks:
        - name: dirstribute host file
          template: src=templates/hosts.j2 dest=/tmp/hosts

 hosts.j2

    127.0.0.1 localhost
    {{ ansible_eth0.ipv4.address }}  {{ ansible_hostname }}

    {% for host in groups['all'] %}
    {{ hostvars[host].ansible_eth0.ipv4.address }}  {{ hostvars[host].ansible_hostname }}
    {% endfor %}

    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    cat /etc/ansible/hosts
    [all]
    192.168.31.10
    192.168.31.12
    ifconfig
    eno16777984: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.31.12  netmask 255.255.255.0  broadcast 192.168.31.255
            inet6 fe80::20c:29ff:fe5c:520e  prefixlen 64  scopeid 0x20<link>
            ether 00:0c:29:5c:52:0e  txqueuelen 1000  (Ethernet)
            RX packets 3645802  bytes 780617081 (744.4 MiB)
            RX errors 32  dropped 8430  overruns 0  frame 0
            TX packets 985366  bytes 509863584 (486.2 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 0  (Local Loopback)
            RX packets 18000  bytes 988080 (964.9 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 18000  bytes 988080 (964.9 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

解决后:

    ansible 192.168.31.12 -m setup -a 'filter=ansible_eno16777984'
    192.168.31.12 | success >> {
        "ansible_facts": {
            "ansible_eno16777984": {
                "active": true,
                "device": "eno16777984",
                "ipv4": {
                    "address": "192.168.31.12",
                    "netmask": "255.255.255.0",
                    "network": "192.168.31.0"
                },
                "ipv6": [
                    {
                        "address": "fe80::20c:29ff:fe5c:520e",
                        "prefix": "64",
                        "scope": "link"
                    }
                ],
                "macaddress": "00:0c:29:5c:52:0e",
                "module": "vmxnet3",
                "mtu": 1500,
                "promisc": false,
                "type": "ether"
            }
        },
        "changed": false
    }

 固更改hosts.j2文件:

    cat hosts.j2
    127.0.0.1 localhost
    {{ ansible_eno16777984.ipv4.address }}  {{ ansible_hostname }}

    {% for host in groups['all'] %}
    {{ hostvars[host].ansible_eno16777984.ipv4.address }}  {{ hostvars[host].ansible_hostname }}
    {% endfor %}

    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts

标签:Ansible,192.168,hosts,host,ansible,ip6,报错,eno16777984
From: https://blog.csdn.net/qq_43606536/article/details/141824123

相关文章

  • goland idea中debug程序报错-debugger could not patch runtime.mallogc
    idea中debugGo程序报错errorlayer=debuggercouldnotpatchruntime.mallogc一、问题场景在idea中配置了Go编程环境,可以运行Go程序,但是无法debug,报错errorlayer=debuggercouldnotpatchruntime.mallogc:notypeentryfound,use‘types’foralistofvalidtypes......
  • [KB]Office安装出现报错30182-39.md
    问题现象:需重新启动很抱歉,遇到问题。请在重启计算机后重试。联机查找更多帮助。错误代码:30182-39反复重启后再执行安装,报错没有任何变化。原因分析:这个问题一般出现在同时安装了Office和Office365然后卸载了他们之后,再重新安装Office时出现;根本的原因就是多个版本共存与OS中,卸载......
  • RHEL8.9中anywhere报错error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key
    本文写于2024年9月2日,维护有效期两年.先说解决方法,进入anywhere的keys目录,即/usr/local/lib/node_modules/anywhere/keys后,备份后生成rsa:2048位的新证书. 最近学习vite+vue,跟着这个文档做的https://segmentfault.com/a/1190000041324864可是在进入dist输出目录后,运......
  • 批量维护工具ansible之yaml与剧本playbook
    一.简介ansible的剧本playbook采用yaml语法,通过yaml语法可以轻松地表示和定义复杂的任务和配置,无论是单台还是多台服务器的管理,ansible都能够提供统一的语法来描述和执行操作,能快速地应对变更、部署和升级。二.yaml语法基本0.运行AnsiblePlaybookansible-playbookdeploy.yml1.YAM......
  • [20240826]奇怪ORA-01031 insufficient privileges报错.txt
    [20240826]奇怪ORA-01031insufficientprivileges报错.txt--//遇到的奇怪ORA-01031insufficientprivileges情况,做一个分析:1.环境:SYS@book01p>@ver2==============================PORT_STRING                  :x86_64/Linux2.4.xxVERSION     ......
  • 遭遇“git”命令找不到的报错,开发者如何迅速应对
    ......
  • ansible自动化运维项目
    在自动化运维中,Ansible是一种强大的工具,它通过无代理的方式来管理配置、部署应用程序和编排复杂任务。一个典型的Ansible自动化运维项目可以包括配置管理、应用部署、补丁更新、系统监控、备份恢复等。以下是如何构建和组织一个Ansible自动化运维项目的详细指南。一、......
  • 网络自动化:利用Python和Ansible实现网络配置管理
    利用Python和Ansible实现网络配置管理是现代网络自动化中的一个关键领域。这个组合使得可以更有效地管理网络设备、减少人为错误、提高网络的可扩展性和一致性。以下是如何利用Python和Ansible实现网络配置管理的详细指南:一、使用Python进行网络自动化Python提......
  • ansible模块
    ansible基础配置ansible的hosts文件sudovim/etc/ansible/hosts添加以下内容client1client2client3测试ansible能否通命令ansible[主机名]-mping-o#-O简洁输出例:ansiblelocalhost-mping-oansibleclient1-mping-o可以看到结果如下ping自己......
  • js常见的报错
    1.UncaughtTypeError:Cannotreadproperty''ofundefined 常见的一种是在渲染UI组件时对于状态的初始化操作不当,当你读取一个未定义的对象的属性或调用其方法时,这个错误会在Chrome中出现。2.TypeError:‘undefined’isnotanobject 这是在Safari中读取属性或调......