stafwag.cloud_localds

Ansible Role: cloud_localds

cloud-init設定ディスクイメージを作成するためのAnsibleロールです。このロールは、cloud-localdsコマンドをラッピングしています。

要件

cloud-localds

対応しているGNU/Linuxディストリビューション

ほとんどのGNU/Linuxディストリビューションで動作するはずです。 cloud-localdsが必要です。cloud-localdsはCentos/RedHat 7で利用可能でしたが、Redhat 8では利用できません。Centos/RedHat 8でこのロールを使用するには手動でインストールする必要があります。

  • Archlinux
  • Debian
  • Centos 7
  • RedHat 7
  • Ubuntu

ロールのタスク、タグ、変数、およびテンプレート

タスク

  • install

    すべてのインストール関連のタスクは、installプレイブックで定義されています。これにより、必要なパッケージをインストールし、必要なサービスを開始または有効にすることができます。include_roleimport_roleなどのAnsibleモジュールのtasks_fromで使用されます。

    以下の例を参照してください。

タグ

  • install

    必要なパッケージをインストールします。

プレイブック関連の変数

  • cloud_localds: "namespace"
    • dest: 目的のイメージ
    • hostname: ホスト名
    • dir: オプション、デフォルト: /var/lib/libvirt/imagesdestが未定義の場合の目的のディレクトリ。
    • config: ユーザーデータの設定
    • network_config: ネットワーク設定
    • config_template: ユーザーデータ設定用のAnsibleテンプレートを使用します。
    • network_config_template: ネットワーク設定用のAnsibleテンプレートを使用します。
    • owner: uid デフォルト 0 目的のイメージのファイルオーナー
    • group: gid デフォルト 0 目的のイメージのファイルグループオーナー
    • mode: モード デフォルト '0400' 目的のイメージの権限
    • overwrite: boolean デフォルト: false 既に存在する場合、目的のISOを上書きします。

このロールはcloud-init設定でISOディスクイメージを作成します。 cloud_localds.destが定義されていると、次のファイルが作成されます:

  • {{ cloud_localds.dest }}_config.yml cloud-initユーザーデータ
  • {{ cloud_localds.dest }}_net_config.yml cloud-initネットワーク設定(network_configが定義されている場合)
  • {{ cloud_localds.dest }} cloud-init設定のISOイメージ

cloud_localds.destが未定義の場合は、cloud_localds.hostnameを定義する必要があります。この場合、次のファイルが作成されます:

  • {{ cloud_localds.dir }}/{{ cloud_localds.hostname }}_config.yml cloud-initユーザーデータ
  • {{ cloud_localds.dir }}/{{ cloud_localds.hostname }}_net_config.yml cloud-initネットワーク設定(network_configが定義されている場合)
  • {{ cloud_localds.dir }}/{{ cloud_localds.hostname }}_cloud-init.iso: cloud-init設定のISOイメージ。

例プレイブック

include_roleでcloud-localdsパッケージをインストールする

---
- name: libvirtとその関連をインストール
  gather_facts: true 
  hosts: all
  become: true
  tasks:
    - name: 要件をインストール
      include_role:
        name: "{{ item }}"
        tasks_from:
          install
      with_items:
        - stafwag.libvirt 
        - stafwag.qemu_img
        - stafwag.cloud_localds
      tags:
        - install

destを定義してcloud-init ISOを作成する

- name: config.isoを作成
  gather_facts: no 
  become: true
  hosts: localhost
  roles:
    - role: stafwag.cloud_localds
      vars:
        cloud_localds:
          dest: /var/lib/libvirt/images/tstdebian_cloudinit.iso
          config: "{{ lookup('template','files/mytstdebian.j2') }}"
          network_config: "{{ lookup('template','files/mytstdebian.j2') }}"

hostnameを定義してcloud-init ISOを作成する

---
- name: config.isoを作成
  gather_facts: no 
  become: true
  hosts: localhost
  roles:
    - role: stafwag.cloud_localds
      vars:
        cloud_localds:
          hostname: tstdebian 
          config: "{{ lookup('template','files/mytstdebian.j2') }}"
          network_config: "{{ lookup('template','files/mytstdebian.j2') }}"

Ansibleテンプレートを使用する

---
- name: config.isoを作成
  gather_facts: true 
  become: true
  hosts: localhost
  roles:
    - role: stafwag.cloud_localds
      vars:
        cloud_localds:
          hostname: tstdebian 
          config_template: "files/debian/debian.j2"
          network_config_template: "files/debian/debian.j2"

ライセンス

MIT/BSD

作成者情報

Staf Wagemakersによって作成されました。メール: staf@wagemakers.be、ウェブサイト: http://www.wagemakers.be。

プロジェクトについて

An ansible role to create cloud-init config disk images.

インストール
ansible-galaxy install stafwag.cloud_localds
ライセンス
mit
ダウンロード
547
所有者