LoginSignup
1
2

More than 1 year has passed since last update.

オフライン環境構築 Ansible編

Last updated at Posted at 2020-09-14

オフライン環境構築 目次へ

概要

オフライン環境で Ansible を構築するための手順。

Ansible は、プロビジョニングのための構成管理ツールである。

詳細は、 プロビジョニングツールの比較 参照。

手順

Ansible は Collection と Role という2つの再利用可能な構成管理単位をもつ。

  1. Collection
  2. Role

構成管理単位毎に、オフラインでの使用方法が異なる。

Collection

オンライン端末

オンライン端末で以下の手順を行う。

  1. Ansible Galaxy でCollectionを検索する。

    image.png

  2. Download tar ballボタンをクリックしてtar ballをダウンロードする。

    image.png

オフライン端末

オフライン端末で以下の手順を行う。

  1. 以下のコマンドを実行してCollectionをインストールする。

    # Command
    $ ansible-galaxy collection install <collection tar ball name>
    
    # Example
    $ ansible-galaxy collection install sindhuparvathi_gopi-ansible_collection_template-1.0.2.tar.gz 
    

Role

Role は、Collectionとは異なりオフライン用のtar ballダウンロード機能がない。

そこで、GitHubからRoleをダウンロードして、tar ballをつくる。

オンライン端末

  1. Ansible GalaxyでRoleを検索する。

    image.png

  2. GitHub Repo ボタンから、Roleのリポジトリを表示する。

    image.png
    出典: https://galaxy.ansible.com/geerlingguy/java

    image.png
    出典: https://github.com/geerlingguy/ansible-role-java

  3. Code ボタンをクリックして、 Download ZIP リンクをクリックし、ソースコードをzip形式でダウンロードする。

    image.png
    出典: https://github.com/geerlingguy/ansible-role-java

オフライン端末

  1. zipファイルをtar.gzで圧縮し直す。

    # Command
    $ unzip <zip file name>.zip
    $ tar czvf <tar file name>.tar.gz <zip file name>/
    
    # Example
    $ unzip ansible-role-java-master.zip
    $ tar czvf ansible-role-java-master.tar.gz ansible-role-java-master/
    
  2. requirements.ymlを作成する。requirements.ymlにRoleの名前、バージョンとRoleのtar ballとの対応関係を定義する。

    requirements.yml
    # Template
    - src: ./<tar file name>.tar.gz
      name: <role name>
      version: <role version>
    
    # Example
    - src: ./ansible-role-java-master.tar.gz
      name: "geerlingguy.java"
      version: "1.10.0"
    
  3. requirements.ymlを使ってRoleをインストールする。

    $ ansible-galaxy install -r requirements.yml 
    
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2