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

Molecule入門

beaverjr
January 21, 2021

 Molecule入門

Molecule入門@社内勉強会

beaverjr

January 21, 2021
Tweet

More Decks by beaverjr

Other Decks in Technology

Transcript

  1. ςετͷྲྀΕ લ४උΠϯετʔϧ QJQ  3PMF࡞੒ NPMFDVMFZNMઃఆ ςετ࣮ߦ NPMFDVMFUFTUͰԼه͕࣮ࢪ͞ΕΔ  DSFBUFQSFQBSFΠϯελϯεΛ࡞੒

    DPOWFSHF3PMFΛ࣮ߦ JEFNQPUFODFႈ౳ੑ֬ೝͷͨΊɺ࠶౓3PMF࣮ߦ WFSJGZςετ࣮ࢪ DMFBOVQEFTUSPZΫϦʔϯΞοϓɺΠϯελϯεͷഁغ
  2. ࠓճͷ3PMF --- # tasks file for mol-test - name: install

    httpd yum: name: httpd state: present - name: start and enable httpd service service: name: httpd state: started enabled: true "QBDIFΛΠϯετʔϧͯ͠ىಈˍࣗಈىಈઃఆ͢Δ3PMF
  3. NPMFDVMFZNM γφϦΦ --- dependency: #Role࣮ߦʹґଘ͢ΔίϯϙʔωϯτΛऔಘ name: galaxy driver: #driverΛࢦఆ name:

    docker lint: | #lintίϚϯυΛࢦఆ set -e yamllint . ansible-lint platforms: #Πϯελϯεͷఆٛ - name: mol-server image: centos:8 command: /sbin/init tmpfs: - /run - /tmp volumes: - /sys/fs/cgroup:/sys/fs/cgroup:ro provisioner: #ansibleΛ࢖͏ name: ansible verifier:ɹ#ansibleΛ࢖͏ name: ansible
  4. WFSJGZZNM ςετఆٛ ——- - name: Verify hosts: all gather_facts: false

    pre_tasks: - name: get httpd statusɹ#httpdͷstatusΛget͢Δ service_facts: tasks: - name: test port 80 openɹ#80൪ϙʔτ͕ۭ͍͍ͯΔ͔֬ೝ wait_for: port: 80 timeout: 5 - name: test http enabled and started #httpdͷstate͕running, status͕enabledʹͳ͍ͬͯΔ͜ͱΛ֬ೝ assert: that: - ansible_facts.services['httpd.service'].state == "running" - ansible_facts.services['httpd.service'].status == "enabled"