【问题标题】:Attach elastic IP's to bastion hosts when provisioned automatically自动配置时将弹性 IP 附加到堡垒主机
【发布时间】:2017-09-26 18:43:39
【问题描述】:
---
- hosts: localhost
  gather_facts: False
  roles:
    - provision_ec2

# this uses a variable defined in the first role of this playbook, provision_ec2.
- hosts: "{{ hostvars['localhost'].bastion_server_group }}"
  become: yes
  become_method: sudo
  roles:
    - hosts_file

# this won't work on bastion servers until we automate a way to connect to the newly provisioned bastion server.
# This would require some proxy command and attaching an elastic IP, then pushing that to the ssh_config.

因为现在我们每次启动新堡垒服务器时都会手动执行上述 cmets,所以我需要您的帮助来了解如何自动化将弹性 IP 附加到新配置的堡垒服务器的过程?我是 Yaml 和 ansible 的新手,最近几周我正在学习 yaml。

- hosts: '{{HOST_GROUP}}'
  gather_facts: False
  roles:
    - { role: ec2_tags, when: server_type != 'bastion' }
    - { role: ec2_tag_volumes, when: server_type == 'app' or server_type == 'util' }

【问题讨论】:

    标签: ansible yaml


    【解决方案1】:

    ec2_eip 模块。在使用 ec2 模块创建实例后使用它。

    示例用法:

    -  ec2_eip:
         region: "{{ region }}"
         state: present
         in_vpc: yes
         device_id: "{{ ec2_result.instances[0].id }}"
         reuse_existing_ip_allowed: yes
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-18
      • 2019-01-09
      • 2021-11-23
      相关资源
      最近更新 更多