Upgrade to Pro — share decks privately, control downloads, hide ads and more …

プレイブックの検証環境をdocker-composeで作った話/playbook test environment by docker-compose

プレイブックの検証環境をdocker-composeで作った話/playbook test environment by docker-compose

あんでぃー

February 12, 2020
Tweet

More Decks by あんでぃー

Other Decks in Technology

Transcript

  1. ຊ൪ ։ൃ ౦ ੢ (Ծʹ͋ͬͯ΋)ߏ੒ҧ͏໰୊ 2ϊʔυΫϥελ → γϯάϧ ౦੢ܥ →

    ౦ͷΈ ػೳ͝ͱʹαʔό෼ׂ → ू໿ͯ͠1୆ IPશવҧ͏
  2. ΍ͬͨ͜ͱ • CentOSͷίϯςφͨ͘͞Μ → ຊ൪؀ڥ΋Ͳ͖ ɾ 1ίϯςφ = 1αʔό(ͷΑ͏ͳԿ͔) •

    docker-composeͰ·ͱΊ্ͯ͛Լ͛ • Ͱ͖Δ͚ͩຊ൪؀ڥΛ࠶ݱ ɾ ݻఆIP ɾ hostsͰ໊લղܾ
  3. FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf

    \ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ஋>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ஋>' | chpasswd --encrypted \ && true CMD [“/sbin/init"]
  4. FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf

    \ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ஋>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ஋>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] CentOSΠϝʔδ͕ ϕʔεͰ
  5. FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf

    \ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ஋>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ஋>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] Ansibleͱ͔ೖΕͯ ※ ࣾ಺؀ڥͷͨΊϓϩΩγܦ༝
  6. FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf

    \ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ஋>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ஋>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] sshΛຊ൪ͱಉ͡ઃ ఆʹͯ͠
  7. FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf

    \ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ஋>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ஋>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] ຊ൪ͱಉ͡Ϣʔβ ࡞ͬͯ
  8. FROM centos:7 RUN true \ && echo ‘proxy=http://proxygate.sample:8080' >> /etc/yum.conf

    \ && yum -y install epel-release \ && yum -y install ansible openssh-clients openssh-server \ && yum -y install libuuid.i686 libuuid.x86_64 libgcc.i686 libgcc.x86_64 \ && yum -y clean all \ && sed -i '$d' /etc/yum.conf \ && true RUN true \ && ssh-keygen -A -N '' \ && sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/ sshd_config \ && true RUN true \ && groupadd -g 1000 sampleuser \ && useradd -N -g sampleuser -u 1000 sampleuser \ && echo ‘sampleuser:$6$<ϋογϡ஋>’ | chpasswd --encrypted \ && echo ‘root:$6$<ϋογϡ஋>' | chpasswd --encrypted \ && true CMD [“/sbin/init"] initϓϩηεΛ࣮ߦ
  9. version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image:

    internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged: true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254
  10. target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged:

    true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254 version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image: internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true Ansibleϗετ λʔήοτϊʔυୡ
  11. version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image:

    internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true ͖ͬ͞ͷ Dockerfile target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged: true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254
  12. version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image:

    internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged: true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254 ݻఆIPׂΓ౰ͯ
  13. version: ‘2' services: master: build: context: ./images/cent7_ansible dockerfile: Dockerfile image:

    internaltest/cent7_ansible hostname: master volumes: - ../ansible_playbook:/playbook working_dir: /playbook networks: infra_net: ipv4_address: 192.168.10.1 extra_hosts: - "master:192.168.10.1" - "target01:192.168.10.2" - "target02:192.168.10.3" - "target03:192.168.10.4" privileged: true hosts target01: image: internaltest/cent7_ansible hostname: target01 networks: infra_net: ipv4_address: 192.168.10.2 privileged: true target02: … target03: … networks: infra_net: driver: bridge ipam: driver: default config: - subnet: 192.168.10.0/24 gateway: 192.168.10.254