1
0

More than 1 year has passed since last update.

DockerでTerraform + Ansibleが動く環境を構築する

Last updated at Posted at 2023-08-02

目的

色々な環境下でTerraformやAnsibleをいちいち構築するのは大変なので、今回はそれらをコンテナ化する。

構築

docker-compose.yml

version: '3.9'

services:
  terasible:
    build:
      context: .
    image: "terasible:1.0"
    container_name: "terasible"
    working_dir: /etc/terasible
    tty: true
    volumes:
      - "/work/:/etc/terasible"

Dockerfile

FROM ubuntu:22.04
RUN apt -y update && apt -y install software-properties-common && apt-add-repository --yes --update ppa:ansible/ansible && apt -y install ansible wget unzip
RUN apt -y install sshpass genisoimage nano vim
RUN wget https://releases.hashicorp.com/terraform/1.5.4/terraform_1.5.4_linux_amd64.zip
RUN unzip terraform_1.5.4_linux_amd64.zip
RUN cp terraform /usr/local/bin

RUN echo "" | echo "" | echo "" | ssh-keygen
RUN cat ~/.ssh/id_rsa.pub

ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" /dev/null

RUN sshpass -p hiyiir ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa.pub root@172.24.20.3
RUN sshpass -p hiyiir ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa.pub shoma@172.24.20.3

確認

ansible

image.png

terraform

image.png

1
0
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
0