簡體   English   中英

Ansible:從列表中設置IP地址

[英]Ansible: setting up IP addresses from the list

我有一個應基於特定主機名分配給主機的IPv6地址列表。 例如:

  • 名稱為“ myhost-dev1”的主機應具有fd00:1 :: 1/64
  • 名稱為“ myhost-dev2”的主機應具有fd00:1 :: 2/64
  • ...
  • 名稱為“ myhost-devN”的主機應具有fd00:1 :: N / 64
  • ...
  • 名稱為“ myhost-qa1”的主機應具有fd00:2 :: 1/64
  • 名稱為“ myhost-qaM”的主機應具有fd00:2 :: M / 64
  • ...
IPv4 addresses are already assigned.
Question: what is the best way to assign these addresses using Ansible?

這是解決方法:

  1. 創建v6.yaml文件:

     myhost-dev1.example.com: fd00:1::1 myhost-dev2.example.com: fd00:1::2 
  2. 添加了以下兩個任務:

     - name: Load IPv6 addresses list include_vars: file: 'v6.yml' name: ipv6_addr - name: Apply IPv6 addresses blockinfile: path: '/etc/sysconfig/network-scripts/ifcfg-eth0' block: | IPV6INIT=yes IPV6ADDR={{ ipv6_addr[ansible_fqdn] }} IPV6_DEFAULTGW=fd00:1::100 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM