jesperberth.az_securitygroup

Az_securitygroup

Microsoft Azureでリソースグループを作成します

要件

Azure SDK が必要です。

pip install 'ansible[azure]'

ロール変数

ロールは次の変数を取ります。

resourcegroup = 作成するリソースグループの名前
location = リソースグループを作成するAzureの場所
tag_owner = 値を持つタグオーナーを作成
tag_project = 値を持つタグプロジェクトを作成
networksecuritygroup_name = セキュリティグループ名
rulename = ルール名
ruleprotocol = プロトコルタイプ Any/Tcp/Udp/Icmp
rulesourceaddress = 任意のソースIP 0.0.0.0/0
ruledestinationportrange = 対象ポート 例: 443(HTTPS用)
ruleaccess = Allow/Deny
rulepriority = 他のルールに対する優先度
ruledirection = インバウンド/アウトバウンド

依存関係

なし

例のプレイブック


- hosts: localhost
  name: Azureセキュリティグループの作成
  vars:
    resourcegroup_name: resourcegroupname
    location: northeurope
    tag_owner: jesper
    tag_project: demoproject
  tasks:
    - name: Azureセキュリティグループ
      include_role:
        name: jesperberth.az_securitygroup
      vars:
        resourcegroup: "{{ resourcegroup_name }}"
        networksecuritygroup_name: SG_Network
        rulename: "AllowHTTPS"
        ruleprotocol: "Tcp"
        rulesourceaddress: 0.0.0.0/0
        ruledestinationportrange: "443"
        ruleaccess: "Allow"
        rulepriority: "101"
        ruledirection: "Inbound"

複数のルールをループで作成する例


- hosts: localhost
  name: Azureセキュリティグループの作成
  vars:
    resourcegroup_name: resourcegroupname
    location: northeurope
    tag_owner: jesper
    tag_project: demoproject
  tasks:
    - name: Azureセキュリティグループ
      include_role:
        name: jesperberth.az_securitygroup
      vars:
        resourcegroup: "{{ resourcegroup_name }}"
        networksecuritygroup_name: "{{ item.networksecuritygroup_name }}"
        rulename: "{{ item.rulename }}"
        ruleprotocol: "{{ item.ruleprotocol }}"
        rulesourceaddress: "{{ item.rulesourceaddress }}"
        ruledestinationportrange: "{{ item.ruledestinationportrange }}"
        ruleaccess: "{{ item.ruleaccess }}"
        rulepriority: "{{ item.rulepriority }}"
        ruledirection: "{{ item.ruledirection }}"
      loop:
        - { networksecuritygroup_name: 'SG_Network', rulename: 'AllowHTTP',  ruleprotocol: 'Tcp', rulesourceaddress: '0.0.0.0/0', ruledestinationportrange: '80', ruleaccess: 'Allow', rulepriority: '102', ruledirection: 'Inbound' }
        - { networksecuritygroup_name: 'SG_Network', rulename: 'AllowHTTPS',  ruleprotocol: 'Tcp', rulesourceaddress: '0.0.0.0/0', ruledestinationportrange: '443', ruleaccess: 'Allow', rulepriority: '103', ruledirection: 'Inbound' }

ライセンス

BSD

著者情報

Jesper Berth

プロジェクトについて

Create Network Security Group In Azure

インストール
ansible-galaxy install jesperberth.az_securitygroup
ライセンス
Unknown
ダウンロード
183
所有者