【问题标题】:changing just netmask in servers debian 9 with playbook ansible使用 playbook ansible 仅更改服务器 debian 9 中的网络掩码
【发布时间】:2021-03-26 07:45:35
【问题描述】:

我只想使用 Ansible 更改 debian9 (/etc/network/interfaces) 中服务器的网络掩码。
你知道我该怎么做吗?

【问题讨论】:

    标签: ansible netmask


    【解决方案1】:

    直接使用以下剧本。

      [rohtash@172 blockinfile]$ cat edit_netmask.yml 
     
       - hosts: localhost
          connection: local
          tasks:
          - replace:
                   path: netmasks
                   regexp: 'netmask 255.255.255.0'
                   replace: 'netmask {{ input }}'
                   backup: yes
    
    
    [rohtash@172 blockinfile]$ ansible-playbook edit_netmask.yml -e input=255.255.255.240
    
    PLAY [localhost] ******************************************************************************************************************************************************************************
    
    TASK [Gathering Facts] ************************************************************************************************************************************************************************
    ok: [localhost]
    
    TASK [replace] ********************************************************************************************************************************************************************************
    changed: [localhost]
    
    PLAY RECAP ************************************************************************************************************************************************************************************
    localhost                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
    

    它将直接替换服务器的网络掩码。

    【讨论】:

      猜你喜欢
      • 2022-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-18
      • 1970-01-01
      相关资源
      最近更新 更多