🐁

ansible-benderでコンテナイメージを作成してみた

2020/09/26に公開

概要

こちらの内容も以前noteで書いた記事を見直ししてリメイクしたものになっています。あの時は、ansible-benderの学習を目的にしており、内部で動いているPodmanとBuildahについて何も知らない状態で書いていたので、見直すと少し変な表現もありましたので、リメイクというよりもう一度書き直して、ansible-benderでコンテナイメージを作成してみたというタイトルに直して書き記していこうと思います。

ansible-benderについて

ansible-benderはAnsible Playbookを使ってコンテナイメージを作成できるツールです。
https://github.com/ansible-community/ansible-bender
かつて、ansible-containerというツールでPlaybookによるコンテナ管理を実現できましたが、現在ansible-containerは開発が終了しております。
https://github.com/ansible/ansible-container
ansible-benderは、ansible-containerの後継機として機能を引き継いだツールとなっております。
pipパッケージからインストールできます。
pip install ansible-bender

機能

公式のGitHubの説明に書いてあるとおりですが、自身の理解のためにいくつかを日本語訳として記載します。

  • buildahを使うことでコンテナイメージをビルドできる
  • ビルド中にボリュームのマウントが可能
  • タスク実行でキャッシュを活用することで高速化
  • タグstop-layeringを付けることで、イメージレイヤーの作成を止めることができる
  • イメージのpushをして他のレジストリやdocker daemonなどにイメージを送ることができる

オプションコマンド

ansible-benderには以下のコマンドが用意されています。

  • build Playbookを指定して新しいコンテナイメージのビルド
  • list-builds ansible-benderでビルドしたイメージのリスト表示
  • get-logs Playbookを実行したときのログを表示
  • inspect <ビルドID> ビルド内の詳細なメタデータの表示。ビルドIDはlist-buildsで取得可
  • push イメージを他の場所へ送る
  • clean ディスク上に存在しないイメージの削除
  • init 変数の用意されたテンプレートPlaybookを作成
テンプレート
---
- name: Containerized version of $project
  hosts: all
  vars:
    a_variable: value
    # configuration specific for ansible-bender
    ansible_bender:
      base_image: fedora:latest
      target_image:
        # command to run by default when invoking the container
        cmd: /command.sh
        name: $project
      working_container:
        volumes:
        # mount this git repo to the working container at /src
        - "{{ playbook_dir }}:/src"
  tasks:
  - name: install dependencies needed to run project $project
    package:
      name:
      - a_package
      - another_package
      state: present

必須要件

冒頭でも述べたように、ansible-benderはpodmanとbuildahが内蔵している必要があります。(当たり前ですが、ansibleも必要です。)
そしてコンテナイメージを作成する際、Pythonのインストールされたベースイメージが必要です。この時、Pythonのバージョンは2系でも3系でも大丈夫です。
こちらの方が紹介しているPythonを含む最小コンテナイメージをあらかじめ作成しておくことをお勧めします。ansible-bender でコンテナイメージを作成する

Dockerfile
FROM debian:buster

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3 && apt-get clean

コンテナイメージの作成

それではansible-benderを使ってコンテナイメージを作成していきます。
作成するコンテナイメージですが、以前紹介したNuxt.jsコンテナイメージをansible-benderで作成できるか検証していきます。
https://zenn.dev/yuta28/articles/37b2990f07d5643cfa56
またベースとなるコンテナイメージは、通常でしたら上に書かれている最小Pythonのイメージでよいのですが、今回はNodeを事前に入れておきたいので、以下のDockerfileを基にしたコンテナイメージを用意しました。

Dockerfile
FROM node:latest
WORKDIR /app
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3 rsync && apt-get clean

ちなみに、rsyncを入れているのはansibleでディレクトリコピーするのに便利なsynchronizeモジュールを利用できるようにするためです。
ベースとなるコンテナイメージが用意できましたら、続いては構成ディレクトリです。

├── Prototype
│   └── app/(Nuxt.jsのひな型)  
└── build_nuxtimage.yml 

前回と同じように事前にNuxt.jsのひな形となる各種一式をローカルに用意します。
dockerモジュールから作成したときはDockerfileでコンテナイメージを作成しましたが、ansible-benderでは、Playbookからコンテナイメージを作成できますので、Dockerfileは今回作っておりません。
Playbookの中身は以下の通りです。

build_nuxtimage.yml
---
- name: Build Nuxt.js image
  hosts: all
  vars:
    ansible_bender:
      base_image: "localhost/node-python3"
      ansible_extra_args: "-vvv"
 
      target_image:
        name: yuta28/bender-test
        working_dir: /app
        environment: 
          NUXT_HOST: 0.0.0.0
        labels:
          built-by: '{{ ansible_user }}'
        cmd: "yarn run dev"        

  tasks:
  - name: Copy Prototype parts
    copy:
      src: "{{ item }}"
      dest: /app/
    with_items:
      - "{{ playbook_dir }}/Prototype/app/package.json"
      - "{{ playbook_dir }}/Prototype/app/yarn.lock"
  
  - name: Yarn install
    command: "yarn install"

  - name: Copy Prototype
    synchronize:
      src: "{{ playbook_dir }}/Prototype/app" 
      dest: /app

Dockerfile内のRUN命令箇所はcommandモジュール、COPY命令箇所はsynchronizeモジュール、CMD命令はtarget_image内のcmd変数に変換してPlaybookでコンテナのイメージ作成文を作ってみました。
作成後、ansible-benderコマンドで実行します。ansible-bender build build_nuxtimage.yml

失敗

結論から話しますと失敗しました。
タスクCopy Prototypeの箇所でsynchronizeモジュールの処理が終わらず、先に進まない状態になりました。

task path: /home/ec2-user/ansible-bender/simple-test/.build_nuxtimage-20200912-021642705039-umrydddzeh.yaml:10
<yuta28-bender-test-20200912-021638690637-cont> ESTABLISH LOCAL CONNECTION FOR USER: ec2-user
<yuta28-bender-test-20200912-021638690637-cont> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/ec2-user/.ansible/tmp/ansible-local-24469ah1fy7m1 `"&& mkdir "` echo /home/ec2-user/.ansible/tmp/ansible-local-24469ah1fy7m1/ansible-tmp-1599877156.9603715-28334-161050357341488 `" && echo ansible-tmp-1599877156.9603715-28334-161050357341488="` echo /home/ec2-user/.ansible/tmp/ansible-local-24469ah1fy7m1/ansible-tmp-1599877156.9603715-28334-161050357341488 `" ) && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/synchronize.py
<yuta28-bender-test-20200912-021638690637-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-24469ah1fy7m1/tmp8nv04tk7 TO /home/ec2-user/.ansible/tmp/ansible-local-24469ah1fy7m1/ansible-tmp-1599877156.9603715-28334-161050357341488/AnsiballZ_synchronize.py
<yuta28-bender-test-20200912-021638690637-cont> EXEC /bin/sh -c 'chmod u+x /home/ec2-user/.ansible/tmp/ansible-local-24469ah1fy7m1/ansible-tmp-1599877156.9603715-28334-161050357341488/ /home/ec2-user/.ansible/tmp/ansible-local-24469ah1fy7m1/ansible-tmp-1599877156.9603715-28334-161050357341488/AnsiballZ_synchronize.py && sleep 0'
<yuta28-bender-test-20200912-021638690637-cont> EXEC /bin/sh -c '/usr/bin/python3.6 /home/ec2-user/.ansible/tmp/ansible-local-24469ah1fy7m1/ansible-tmp-1599877156.9603715-28334-161050357341488/AnsiballZ_synchronize.py && sleep 0'

はっきりとした原因は掴めませんが、コピーするファイルの量が多いことが原因ではないかと推測しました。

$ ls -R app | wc -l
36358 ←3万以上のファイル群

どうしたものかと途方にくれていたところ、ansibleに詳しいフォロワーの方から大きなファイルをansibleで直接送るのではなく、AWS S3を経由して送ったほうがよいというアドバイスをいただきましたので、aws_s3というモジュールがansible-benderで使えるか検証するためのテスト用Playbookを作成しました。

build_nuxtimage.yml
---
- name: Build Nuxt.js image
  hosts: all
  gather_facts: false
  vars:
    ansible_python_interpreter: /usr/bin/python3
    ansible_bender:
      base_image: "localhost/node-python3"
      ansible_extra_args: "-vvv"

      target_image:
        name: yuta28/bender-test
        working_dir: /app
        environment: 
          NUXT_HOST: 0.0.0.0
        labels:
          built-by: '{{ ansible_user }}'      

  tasks:
  - name: Upload Prototype to S3
    aws_s3:
      bucket: ansible-bender-bucket
      object: app/nuxt.config.js
      src: "{{ playbook_dir }}/Prototype/app/nuxt.config.js"
      mode: put

こちらのPlaybookを実行すると以下のエラーが出ました。

TASK [Upload Prototype to S3] **********************************************************************************************************************************************************
task path: /home/ec2-user/ansible-bender/simple-test/.build_nuxtimage-20200912-024316468577-jjfznsazui.yaml:5
<yuta28-bender-test-20200912-024312325590-cont> RUN [b'buildah', b'mount', b'--', b'yuta28-bender-test-20200912-024312325590-cont']
<yuta28-bender-test-20200912-024312325590-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200912-024312325590-cont', b'/bin/sh', b'-c', b'( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1599878598.4473948-102621-228656985697566 `" && echo ansible-tmp-1599878598.4473948-102621-228656985697566="` echo /tmp/ansible-tmp-1599878598.4473948-102621-228656985697566 `" ) && sleep 0']
<yuta28-bender-test-20200912-024312325590-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200912-024312325590-cont', b'/bin/sh', b'-c', b'test -e /home/ec2-user/ansible-bender/simple-test/Prototype/app/nuxt.config.js && sleep 0']
Using module file /usr/lib/python3.6/site-packages/ansible/modules/cloud/amazon/aws_s3.py
<yuta28-bender-test-20200912-024312325590-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-1025297iswwqko/tmpddey__6x TO /tmp/ansible-tmp-1599878598.4473948-102621-228656985697566/AnsiballZ_aws_s3.py
<yuta28-bender-test-20200912-024312325590-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200912-024312325590-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599878598.4473948-102621-228656985697566/ /tmp/ansible-tmp-1599878598.4473948-102621-228656985697566/AnsiballZ_aws_s3.py && sleep 0']
<yuta28-bender-test-20200912-024312325590-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200912-024312325590-cont', b'/bin/sh', b'-c', b'/usr/bin/python3 /tmp/ansible-tmp-1599878598.4473948-102621-228656985697566/AnsiballZ_aws_s3.py && sleep 0']
<yuta28-bender-test-20200912-024312325590-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200912-024312325590-cont', b'/bin/sh', b'-c', b'rm -f -r /tmp/ansible-tmp-1599878598.4473948-102621-228656985697566/ > /dev/null 2>&1 && sleep 0']
<yuta28-bender-test-20200912-024312325590-cont> RUN [b'buildah', b'umount', b'--', b'yuta28-bender-test-20200912-024312325590-cont']
fatal: [yuta28-bender-test-20200912-024312325590-cont]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "aws_access_key": null,
            "aws_secret_key": null,
            "bucket": "ansible-bender-bucket",
            "debug_botocore_endpoint_logs": false,
            "dest": null,
            "dualstack": false,
            "ec2_url": null,
            "encrypt": true,
            "encryption_kms_key_id": null,
            "encryption_mode": "AES256",
            "expiry": 600,
            "headers": null,
            "ignore_nonexistent_bucket": false,
            "marker": "",
            "max_keys": 1000,
            "metadata": null,
            "mode": "put",
            "object": "app/nuxt.config.js",
            "overwrite": "always",
            "permission": [
                "private"
            ],
            "prefix": "",
            "profile": null,
            "region": null,
            "retries": 0,
            "rgw": false,
            "s3_url": null,
            "security_token": null,
            "src": "/home/ec2-user/ansible-bender/simple-test/Prototype/app/nuxt.config.js",
            "validate_certs": true,
            "version": null
        }
    },
    "msg": "Failed to import the required Python library (botocore or boto3) on ip-172-31-8-50.ap-northeast-1.compute.internal's Python /usr/bin/python3. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}

必要なPythonライブラリが不足していると出ていますが、boto3もbotocoreもインストールはされています。
Python interpreterの指定が間違っているのというのがよく分からず、一応冒頭で明示的にansible_python_interpreter: /usr/bin/python3を指定しましたが、結果は変わりませんでした。
こちらの内容はteratailにも質問を投稿していますので、わかるかたがいましたらご教授お願いいたします。
https://teratail.com/questions/291301

プランB

次に挑戦してみたのが、appディレクトリをアーカイブして、コンテナ内で展開する方法です。
Ansibleにはファイルの圧縮や展開を実施してくれうモジュールがありますので、それを使います。
archive
unarchive
そして出来上がったPlaybookがこちらです。

build_nuxtimage.yml
---
- name: Build Nuxt.js image
  hosts: all
  gather_facts: false
  vars:
    ansible_python_interpreter: /usr/bin/python3
    ansible_bender:
      base_image: "localhost/node-python3"
      ansible_extra_args: "-vvv"

      target_image:
        name: yuta28/bender-test
        working_dir: /app
        environment:
          NUXT_HOST: 0.0.0.0
        labels:
          built-by: '{{ ansible_user }}'
        cmd: "yarn run dev"

  tasks:
  - name: Copy Prototype parts
    copy:
      src: "{{ item }}"
      dest: /app/
    with_items:
      - "{{ playbook_dir }}/Prototype/app/package.json"
      - "{{ playbook_dir }}/Prototype/app/yarn.lock"

  - name: Yarn install
    command: "yarn install"

  - name: Archive app directory
    delegate_to: localhost
    archive:
      path: "{{ playbook_dir }}/Prototype/app"
      dest: "{{ playbook_dir }}/Prototype/app.tar.gz"
      format: gz

  - name: Unpacks app.tar.gz
    unarchive:
      src: "{{ playbook_dir }}/Prototype/app.tar.gz"
      dest: /

archiveモジュールですが、リモート先のソースファイルをアーカイブするモジュールのため、ローカルマシン上にあるソースファイルをアーカイブするには、delegate_toでlocalhostを指定することでローカルマシンにあるappディレクトリをアーカイブできます。
アーカイブできましたら、unarchiveモジュールでコンテナ先にコピーして展開します。(copyもやってくれるので便利なモジュールですね)
このPlaybookを実行した結果がこちらです。

$ ansible-bender build build_nuxtimage.yml 
ansible-playbook 2.9.13
  config file = /tmp/ab_x4m8plk/ansible.cfg
  configured module search path = ['/home/ec2-user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /tmp/ab_x4m8plk/ansible.cfg as config file
host_list declined parsing /tmp/ab_x4m8plk/inventory as it did not pass its verify_file() method
script declined parsing /tmp/ab_x4m8plk/inventory as it did not pass its verify_file() method
auto declined parsing /tmp/ab_x4m8plk/inventory as it did not pass its verify_file() method
Parsed /tmp/ab_x4m8plk/inventory inventory source with ini plugin

PLAYBOOK: .build_nuxtimage-20200913-071938404664-rjqqvxkjpc.yaml *********************************************************************************************
1 plays in .build_nuxtimage-20200913-071938404664-rjqqvxkjpc.yaml

PLAY [Build Nuxt.js image] ***********************************************************************************************************************************
META: ran handlers

TASK [Copy Prototype parts] **********************************************************************************************************************************
task path: /home/ec2-user/ansible-bender/simple-test/.build_nuxtimage-20200913-071938404664-rjqqvxkjpc.yaml:5
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'mount', b'--', b'yuta28-bender-test-20200913-071934769597-cont']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493 `" && echo ansible-tmp-1599981579.9843893-85539-240769061862493="` echo /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493 `" ) && sleep 0']
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/stat.py
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-85531c92iy6sw/tmptlan88hf TO /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/AnsiballZ_stat.py
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/ /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/AnsiballZ_stat.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'/usr/bin/python3 /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/AnsiballZ_stat.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/ansible-bender/simple-test/Prototype/app/package.json TO /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/source
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/ /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/source && sleep 0']
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/copy.py
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-85531c92iy6sw/tmpsvj89bye TO /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/AnsiballZ_copy.py
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/ /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/AnsiballZ_copy.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'/usr/bin/python3 /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/AnsiballZ_copy.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'rm -f -r /tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/ > /dev/null 2>&1 && sleep 0']
changed: [yuta28-bender-test-20200913-071934769597-cont] => (item=/home/ec2-user/ansible-bender/simple-test/Prototype/app/package.json) => {
    "ansible_loop_var": "item",
    "changed": true,
    "checksum": "6d2c4a9be11c23a400eadada86083955716f1745",
    "dest": "/app/package.json",
    "diff": [],
    "gid": 0,
    "group": "root",
    "invocation": {
        "module_args": {
            "_original_basename": "package.json",
            "attributes": null,
            "backup": false,
            "checksum": "6d2c4a9be11c23a400eadada86083955716f1745",
            "content": null,
            "delimiter": null,
            "dest": "/app/package.json",
            "directory_mode": null,
            "follow": false,
            "force": true,
            "group": null,
            "local_follow": null,
            "mode": null,
            "owner": null,
            "regexp": null,
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": "/tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/source",
            "unsafe_writes": null,
            "validate": null
        }
    },
    "item": "/home/ec2-user/ansible-bender/simple-test/Prototype/app/package.json",
    "md5sum": "094ac03c6b1e84ee4acd6cdadd40b9d5",
    "mode": "0644",
    "owner": "root",
    "size": 485,
    "src": "/tmp/ansible-tmp-1599981579.9843893-85539-240769061862493/source",
    "state": "file",
    "uid": 0
}
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120 `" && echo ansible-tmp-1599981586.3151097-85539-278767227407120="` echo /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120 `" ) && sleep 0']
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/stat.py
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-85531c92iy6sw/tmphc5g7kam TO /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/AnsiballZ_stat.py
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/ /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/AnsiballZ_stat.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'/usr/bin/python3 /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/AnsiballZ_stat.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/ansible-bender/simple-test/Prototype/app/yarn.lock TO /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/source
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/ /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/source && sleep 0']
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/copy.py
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-85531c92iy6sw/tmp_c7ux2zf TO /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/AnsiballZ_copy.py
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/ /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/AnsiballZ_copy.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'/usr/bin/python3 /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/AnsiballZ_copy.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'rm -f -r /tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/ > /dev/null 2>&1 && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'umount', b'--', b'yuta28-bender-test-20200913-071934769597-cont']
changed: [yuta28-bender-test-20200913-071934769597-cont] => (item=/home/ec2-user/ansible-bender/simple-test/Prototype/app/yarn.lock) => {
    "ansible_loop_var": "item",
    "changed": true,
    "checksum": "61b41c179bdef04f6f2825e48b0770043ff10c60",
    "dest": "/app/yarn.lock",
    "diff": [],
    "gid": 0,
    "group": "root",
    "invocation": {
        "module_args": {
            "_original_basename": "yarn.lock",
            "attributes": null,
            "backup": false,
            "checksum": "61b41c179bdef04f6f2825e48b0770043ff10c60",
            "content": null,
            "delimiter": null,
            "dest": "/app/yarn.lock",
            "directory_mode": null,
            "follow": false,
            "force": true,
            "group": null,
            "local_follow": null,
            "mode": null,
            "owner": null,
            "regexp": null,
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": "/tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/source",
            "unsafe_writes": null,
            "validate": null
        }
    },
    "item": "/home/ec2-user/ansible-bender/simple-test/Prototype/app/yarn.lock",
    "md5sum": "aff34cb85c63fed89b6999d3f0a52206",
    "mode": "0644",
    "owner": "root",
    "size": 437538,
    "src": "/tmp/ansible-tmp-1599981586.3151097-85539-278767227407120/source",
    "state": "file",
    "uid": 0
}

TASK [Yarn install] ******************************************************************************************************************************************
task path: /home/ec2-user/ansible-bender/simple-test/.build_nuxtimage-20200913-071938404664-rjqqvxkjpc.yaml:9
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'mount', b'--', b'yuta28-bender-test-20200913-071934769597-cont']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1599981625.6282134-86823-199173905670220 `" && echo ansible-tmp-1599981625.6282134-86823-199173905670220="` echo /tmp/ansible-tmp-1599981625.6282134-86823-199173905670220 `" ) && sleep 0']
Using module file /usr/lib/python3.6/site-packages/ansible/modules/commands/command.py
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-85531c92iy6sw/tmpzopf7c5d TO /tmp/ansible-tmp-1599981625.6282134-86823-199173905670220/AnsiballZ_command.py
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981625.6282134-86823-199173905670220/ /tmp/ansible-tmp-1599981625.6282134-86823-199173905670220/AnsiballZ_command.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'/usr/bin/python3 /tmp/ansible-tmp-1599981625.6282134-86823-199173905670220/AnsiballZ_command.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'rm -f -r /tmp/ansible-tmp-1599981625.6282134-86823-199173905670220/ > /dev/null 2>&1 && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'umount', b'--', b'yuta28-bender-test-20200913-071934769597-cont']
changed: [yuta28-bender-test-20200913-071934769597-cont] => {
    "changed": true,
    "cmd": [
        "yarn",
        "install"
    ],
    "delta": "0:00:40.856951",
    "end": "2020-09-13 07:21:09.170809",
    "invocation": {
        "module_args": {
            "_raw_params": "yarn install",
            "_uses_shell": false,
            "argv": null,
            "chdir": null,
            "creates": null,
            "executable": null,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true,
            "warn": true
        }
    },
    "rc": 0,
    "start": "2020-09-13 07:20:28.313858",
    "stderr": "warning \" > bootstrap@4.5.2\" has unmet peer dependency \"jquery@1.9.1 - 3\".\nwarning \" > bootstrap@4.5.2\" has unmet peer dependency \"popper.js@^1.16.1\".\nwarning \"bootstrap-vue > portal-vue@2.1.7\" has unmet peer dependency \"vue@^2.5.18\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-async-generators@7.8.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-class-properties@7.10.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-json-strings@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-logical-assignment-operators@7.10.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-nullish-coalescing-operator@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-numeric-separator@7.10.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-object-rest-spread@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-optional-catch-binding@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-optional-chaining@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \" > @vue/test-utils@1.1.0\" has unmet peer dependency \"vue@2.x\".\nwarning \" > @vue/test-utils@1.1.0\" has unmet peer dependency \"vue-template-compiler@^2.x\".\nwarning \" > babel-core@7.0.0-bridge.0\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \" > babel-jest@26.3.0\" has unmet peer dependency \"@babel/core@^7.0.0\".\nwarning \"babel-jest > babel-preset-jest@26.3.0\" has unmet peer dependency \"@babel/core@^7.0.0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax@0.1.3\" has unmet peer dependency \"@babel/core@^7.0.0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-bigint@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-import-meta@7.10.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".\nwarning \" > vue-jest@3.0.6\" has unmet peer dependency \"vue@^2.x\".\nwarning \" > vue-jest@3.0.6\" has unmet peer dependency \"vue-template-compiler@^2.x\".",
    "stderr_lines": [
        "warning \" > bootstrap@4.5.2\" has unmet peer dependency \"jquery@1.9.1 - 3\".",
        "warning \" > bootstrap@4.5.2\" has unmet peer dependency \"popper.js@^1.16.1\".",
        "warning \"bootstrap-vue > portal-vue@2.1.7\" has unmet peer dependency \"vue@^2.5.18\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-async-generators@7.8.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-class-properties@7.10.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-json-strings@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-logical-assignment-operators@7.10.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-nullish-coalescing-operator@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-numeric-separator@7.10.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-object-rest-spread@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-optional-catch-binding@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-optional-chaining@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \" > @vue/test-utils@1.1.0\" has unmet peer dependency \"vue@2.x\".",
        "warning \" > @vue/test-utils@1.1.0\" has unmet peer dependency \"vue-template-compiler@^2.x\".",
        "warning \" > babel-core@7.0.0-bridge.0\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \" > babel-jest@26.3.0\" has unmet peer dependency \"@babel/core@^7.0.0\".",
        "warning \"babel-jest > babel-preset-jest@26.3.0\" has unmet peer dependency \"@babel/core@^7.0.0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax@0.1.3\" has unmet peer dependency \"@babel/core@^7.0.0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-bigint@7.8.3\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \"babel-jest > babel-preset-jest > babel-preset-current-node-syntax > @babel/plugin-syntax-import-meta@7.10.4\" has unmet peer dependency \"@babel/core@^7.0.0-0\".",
        "warning \" > vue-jest@3.0.6\" has unmet peer dependency \"vue@^2.x\".",
        "warning \" > vue-jest@3.0.6\" has unmet peer dependency \"vue-template-compiler@^2.x\"."
    ],
    "stdout": "yarn install v1.22.5\n[1/4] Resolving packages...\n[2/4] Fetching packages...\ninfo fsevents@2.1.3: The platform \"linux\" is incompatible with this module.\ninfo \"fsevents@2.1.3\" is an optional dependency and failed compatibility check. Excluding it from installation.\ninfo fsevents@1.2.13: The platform \"linux\" is incompatible with this module.\ninfo \"fsevents@1.2.13\" is an optional dependency and failed compatibility check. Excluding it from installation.\n[3/4] Linking dependencies...\n[4/4] Building fresh packages...\nDone in 40.62s.",
    "stdout_lines": [
        "yarn install v1.22.5",
        "[1/4] Resolving packages...",
        "[2/4] Fetching packages...",
        "info fsevents@2.1.3: The platform \"linux\" is incompatible with this module.",
        "info \"fsevents@2.1.3\" is an optional dependency and failed compatibility check. Excluding it from installation.",
        "info fsevents@1.2.13: The platform \"linux\" is incompatible with this module.",
        "info \"fsevents@1.2.13\" is an optional dependency and failed compatibility check. Excluding it from installation.",
        "[3/4] Linking dependencies...",
        "[4/4] Building fresh packages...",
        "Done in 40.62s."
    ]
}

TASK [Archive app directory] *********************************************************************************************************************************
task path: /home/ec2-user/ansible-bender/simple-test/.build_nuxtimage-20200913-071938404664-rjqqvxkjpc.yaml:10
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: ec2-user
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1599981718.3019533-89318-73459036901194 `" && echo ansible-tmp-1599981718.3019533-89318-73459036901194="` echo /tmp/ansible-tmp-1599981718.3019533-89318-73459036901194 `" ) && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/archive.py
<localhost> PUT /home/ec2-user/.ansible/tmp/ansible-local-85531c92iy6sw/tmpai8exkec TO /tmp/ansible-tmp-1599981718.3019533-89318-73459036901194/AnsiballZ_archive.py
<localhost> EXEC /bin/sh -c 'chmod u+x /tmp/ansible-tmp-1599981718.3019533-89318-73459036901194/ /tmp/ansible-tmp-1599981718.3019533-89318-73459036901194/AnsiballZ_archive.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 /tmp/ansible-tmp-1599981718.3019533-89318-73459036901194/AnsiballZ_archive.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /tmp/ansible-tmp-1599981718.3019533-89318-73459036901194/ > /dev/null 2>&1 && sleep 0'
changed: [yuta28-bender-test-20200913-071934769597-cont] => {
    "archived": [
        "/home/ec2-user/ansible-bender/simple-test/Prototype/app/.babelrc",
        "/home/ec2-user/ansible-bender/simple-test/Prototype/app/.editorconfig",
        "/home/ec2-user/ansible-bender/simple-test/Prototype/app/.gitignore",
        "/home/ec2-user/ansible-bender/simple-test/Prototype/app/README.md",
〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜省略〜〜〜〜〜〜〜〜〜〜〜〜〜〜

TASK [Unpacks app.tar.gz] ************************************************************************************************************************************
task path: /home/ec2-user/ansible-bender/simple-test/.build_nuxtimage-20200913-071938404664-rjqqvxkjpc.yaml:14
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'mount', b'--', b'yuta28-bender-test-20200913-071934769597-cont']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'( umask 77 && mkdir -p "` echo /tmp `"&& mkdir "` echo /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779 `" && echo ansible-tmp-1599981807.6501725-89365-211504907263779="` echo /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779 `" ) && sleep 0']
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/stat.py
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-85531c92iy6sw/tmpme8oa0lm TO /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/AnsiballZ_stat.py
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/ /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/AnsiballZ_stat.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'/usr/bin/python3 /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/AnsiballZ_stat.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/ansible-bender/simple-test/Prototype/app.tar.gz TO /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/source
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/ /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/source && sleep 0']
Using module file /usr/lib/python3.6/site-packages/ansible/modules/files/unarchive.py
<yuta28-bender-test-20200913-071934769597-cont> PUT /home/ec2-user/.ansible/tmp/ansible-local-85531c92iy6sw/tmppn591my3 TO /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/AnsiballZ_unarchive.py
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'chmod u+x /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/ /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/AnsiballZ_unarchive.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'/usr/bin/python3 /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/AnsiballZ_unarchive.py && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'run', b'--', b'yuta28-bender-test-20200913-071934769597-cont', b'/bin/sh', b'-c', b'rm -f -r /tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/ > /dev/null 2>&1 && sleep 0']
<yuta28-bender-test-20200913-071934769597-cont> RUN [b'buildah', b'umount', b'--', b'yuta28-bender-test-20200913-071934769597-cont']
changed: [yuta28-bender-test-20200913-071934769597-cont] => {
    "changed": true,
    "dest": "/",
    "extract_results": {
        "cmd": [
            "/bin/tar",
            "--extract",
            "-C",
            "/",
            "-z",
            "-f",
            "/tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/source"
        ],
        "err": "",
        "out": "",
        "rc": 0
    },
    "gid": 0,
    "group": "root",
    "handler": "TgzArchive",
    "invocation": {
        "module_args": {
            "attributes": null,
            "backup": null,
            "content": null,
            "creates": null,
            "delimiter": null,
            "dest": "/",
            "directory_mode": null,
            "exclude": [],
            "extra_opts": [],
            "follow": false,
            "force": null,
            "group": null,
            "keep_newer": false,
            "list_files": false,
            "mode": null,
            "owner": null,
            "regexp": null,
            "remote_src": false,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": "/tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/source",
            "unsafe_writes": null,
            "validate_certs": true
        }
    },
    "mode": "0755",
    "owner": "root",
    "size": 39,
    "src": "/tmp/ansible-tmp-1599981807.6501725-89365-211504907263779/source",
    "state": "directory",
    "uid": 0
}
META: ran handlers
META: ran handlers

PLAY RECAP ***************************************************************************************************************************************************
yuta28-bender-test-20200913-071934769597-cont : ok=4    changed=4    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Getting image source signatures
Copying blob sha256:b323b70996e4f6d603c331669ac44cf6234a2e22002d3686e9c88398c6911c25
Copying blob sha256:e8847c2734e1bec913fbb00dbd638e9bff6c42f699bbeb897728e234cf1a6e72
Copying blob sha256:a4c504f73441d711e6e71e5c177a772efe4d500c2d97b2a1358ea65edc98e8d5
Copying blob sha256:ef5de533cb53783465669a60fc9b0b1c782d319c5c8991fe9868f3be8be8e58b
Copying blob sha256:cbe6bbd0c86ff46f87950e109e891445a085c9bbf5af737b0ae3871d782e5335
Copying blob sha256:174e334f3f463272eeba0021b8b2c54a8891abc0c74201bbd98e87e8c00524e2
Copying blob sha256:e404bec46f40991019fbf239256326c48afb7672768755740a6ba862d431e5c6
Copying blob sha256:58b4b808347b3cdc40003e905f03059f37ae8cf169e91ecf25250e475e27728f
Copying blob sha256:24a8e30559a7f9f31238761563cc4ab907863039cbc3778449ca8c55f50ecc4a
Copying blob sha256:9b6e6b48454d80e68f9709e8b82abfe7bd0d059464b9c1796d462601ea59182f
Copying blob sha256:9f9869f02922117d69ea1b18239a9d55ac8e6d4ca578fc7ef226d20c3e7424f2
Copying config sha256:ddcc7b1e45f6483f9df7f0d19a17969aa27f92f2e6f77962d3c87c29f32c8186
Writing manifest to image destination
Storing signatures
ddcc7b1e45f6483f9df7f0d19a17969aa27f92f2e6f77962d3c87c29f32c8186
Image 'yuta28/bender-test' was built successfully \o/

$ podman images
REPOSITORY                     TAG      IMAGE ID       CREATED          SIZE
localhost/yuta28/bender-test   latest   ddcc7b1e45f6   32 minutes ago   1.41 GB
localhost/node-python3         latest   79003b61771b   3 hours ago      990 MB
docker.io/library/node         latest   173eeb895217   2 days ago       972 MB

コンテナイメージlocalhost/yuta28/bender-teatが作成されましたので、起動できるか確認します。

$ podman run --rm -it -p 8080:3000 localhost/yuta28/bender-test:latest
yarn run v1.22.5
$ nuxt

 WARN  mode option is deprecated. You can safely remove it from nuxt.config                                                                                                          07:59:19


   ╭────────────────────────────────────────╮
   │                                        │
   │   Nuxt.js @ v2.14.5                    │
   │                                        │
   │   ▸ Environment: development           │
   │   ▸ Rendering:   server-side           │
   │   ▸ Target:      server                │
   │                                        │
   │   Listening: http://10.0.2.100:3000/   │
   │                                        │
   ╰────────────────────────────────────────╯

ℹ Preparing project for development                                                                                                                                                  07:59:21
ℹ Initial build may take a while                                                                                                                                                     07:59:21
✔ Builder initialized                                                                                                                                                                07:59:21
✔ Nuxt files generated                                                                                                                                                               07:59:21

✔ Client
  Compiled successfully in 8.21s

✔ Server
  Compiled successfully in 6.60s

ℹ Waiting for file changes                                                                                                                                                           07:59:30
ℹ Memory usage: 212 MB (RSS: 320 MB)                                                                                                                                                 07:59:30
ℹ Listening on: http://10.0.2.100:3000/                                                                                                                                              07:59:30

 $ podman ps
CONTAINER ID  IMAGE                                COMMAND       CREATED         STATUS             PORTS                   NAMES
fe83f066139c  localhost/yuta28/bender-test:latest  yarn run dev  12 minutes ago  Up 12 minutes ago  0.0.0.0:8080->3000/tcp  strange_moore

コンテナが起動でき、ブラウザからNuxt.jsのサンプルページにアクセスできました。

反省点

DockerfileからPlaybookへ変更してコンテナイメージ作成を行ないましたが、いくつかやり方が分からず、残タスクとして残っているものがあります。

telemetryによるデータ収集問い合わせの無効化設定について

Dockerfileでは以下の環境変数を設定しました。
NUXT_TELEMETRY_DISABLED=1
こちらですが、Nuxt機能の統計情報の収集問い合わせを無視する設定です。デフォルトでは有効化されており、最初にコンテナを起動すると以下のメッセージが出てきます。

yarn run v1.22.5
$ nuxt

ℹ NuxtJS collects completely anonymous data about usage.                                                                                                      11:21:11
  This will help us improving Nuxt developer experience over the time.
  Read more on https://git.io/nuxt-telemetry

? Are you interested in participation? Yes ← Yes/Noで選択

起動のたびに聞かれるのが煩わしいので設定で無効化しようと、変数をPlaybookに組み込みましたが、以下のエラーが出て失敗しました。

$ ansible-bender build simple-test/build_nuxtimage.yml 
There was an error during execution: variable /target_image/environment/NUXT_TELEMETRY_DISABLED is set to 1, which is not of type string

環境変数がstring型でないと怒られました。NUXT_TELEMETRY_DISABLEDはboolean型ですが、ansible-benderの環境変数はstring型のものしかセットできないのでしょうか?
対処方法としましては、app/nuxt.config.js内に以下の設定を追加しました。

nuxt.config.js
export default {
~~~~~末尾追加~~~~~
  telemetry: false
}

noneイメージが溜まり続ける

Playbook実行直後にイメージリストを調べると以下のように途中過程で作られたnoneイメージがたくさん溜まってきます。

$ podman images
REPOSITORY                     TAG        IMAGE ID       CREATED       SIZE
localhost/yuta28/bender-test   latest     3b568629853d   2 hours ago   1.41 GB
<none>                         <none>     30f38e724bd8   2 hours ago   1.41 GB
<none>                         <none>     2c3401135802   2 hours ago   1.41 GB
<none>                         <none>     ab36ebfbcb82   2 hours ago   1.41 GB
<none>                         <none>     0c15be92f176   2 hours ago   992 MB
<none>                         <none>     0f4f0464e1e9   2 hours ago   992 MB
<none>                         <none>     f19ac9e8da69   2 hours ago   991 MB
localhost/node-python3         latest     73bb42b858aa   5 days ago    991 MB
localhost/debian-python3       buster     af956b4f0450   8 days ago    177 MB
docker.io/library/node         latest     40ce906a3734   11 days ago   973 MB
docker.io/library/python       3-alpine   44fceb565b2a   4 weeks ago   44.7 MB
docker.io/library/debian       buster     ee11c54e6bb7   5 weeks ago   119 MB

作成後にpodman image pruneで消していますが、この辺なんとかならないのでしょうか?

$ podman image prune 
f19ac9e8da698db6fc77e469a24e7e1fa078e595338cf6b6f99961b1f2cb375d
0f4f0464e1e9ec409b6359bce2c8c4bf892dd592f01d1361d2807afd811ef9f0
0c15be92f176a7c52b7d43b664f60714b07e8955bc544bea732e9dc33ae25d4a
ab36ebfbcb829a626919ed45155b82be8e885c5fc82d91c86e910ac6173b4fb4
2c340113580260ccac3b2bfa7341927f6faba8355b21d6e2893556eed4161e99
30f38e724bd8c9af6ce74fe7eb733181e97c7ee77dc6c3b6a593853a6fa70f28
$ podman images
REPOSITORY                     TAG        IMAGE ID       CREATED       SIZE
localhost/yuta28/bender-test   latest     3b568629853d   2 hours ago   1.41 GB
localhost/node-python3         latest     73bb42b858aa   5 days ago    991 MB
localhost/debian-python3       buster     af956b4f0450   8 days ago    177 MB
docker.io/library/node         latest     40ce906a3734   11 days ago   973 MB
docker.io/library/python       3-alpine   44fceb565b2a   4 weeks ago   44.7 MB
docker.io/library/debian       buster     ee11c54e6bb7   5 weeks ago   119 MB

所感

ansible-benderを使った感想としては思ったよりも使いにくいと感じました。
ansible-containerはコンテナイメージの作成からコンテナ起動、イメージのプッシュができたのですが、ansible-benderはコンテナイメージの作成だけに留まっており、機能としては減ったように感じます。
また、ansible-benderの開発はあまり活発ではなく、最新リリースが昨年の12月、プルリクも今年の5/18が最後になっております。(2020/9現在)
正直なところAnsibleでコンテナ管理するメリットがあまり感じられず、docker-composeやKubernetesでコンテナ管理をしたほうがいいじゃんと言われたら何も言えません。
Ansibleでコンテナ管理するメリットやansible-benderが上記2つよりも優れている点がありましたらぜひともコメントにてアドバイスお願いいたします。

LT資料

この記事を基にしたLTをしましたので資料を置いておきます。

GitHubで編集を提案

Discussion