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

Ansibleで3台のビルドサーバーを3分で構築した話 / Set up build serv...

oohira
December 20, 2016

Ansibleで3台のビルドサーバーを3分で構築した話 / Set up build servers in 3 min by Ansible

oohira

December 20, 2016
Tweet

More Decks by oohira

Other Decks in Programming

Transcript

  1. 実行 $ ansible-playbook -i hosts playbook.yml PLAY *************************************************************************** TASK [setup]

    ******************************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] TASK [test connection] ********************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] PLAY RECAP ********************************************************************* 192.168.74.140 : ok=2 changed=0 unreachable=0 failed=0 192.168.74.141 : ok=2 changed=0 unreachable=0 failed=0 192.168.74.142 : ok=2 changed=0 unreachable=0 failed=0
  2. tasks: - name: Install Git yum: name: git state: present

    - name: Add symbolic link for Git file: src: /usr/bin/git dest: /usr/local/bin/git state: link force: yes yum, file
  3. tasks: - name: Add rsadmin user user: name: rsadmin uid:

    5004 password: "{{'hoge'|password_hash('sha512')}}" state: present user
  4. tasks: - name: Install Oracle JDK unarchive: src: ./file/jdk-8u45-linux-x64.tar.gz dest:

    /usr/java creates: /usr/java/jdk1.8.0_45 - name: Update alternative JDK alternatives: name: java link: /usr/bin/java path: /usr/java/jdk1.8.0_45/bin/java unarchive, alternative
  5. $ cat playbook.yml - hosts: build user: root tasks: -

    name: Install Git yum: name: git state: present yumの場合
  6. 実行1回目 $ ansible-playbook -i hosts playbook.yml PLAY *************************************************************************** TASK [setup]

    ******************************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] TASK [Install Git] ************************************************************* changed: [192.168.74.140] changed: [192.168.74.141] changed: [192.168.74.142] PLAY RECAP ********************************************************************* 192.168.74.140 : ok=2 changed=1 unreachable=0 failed=0 192.168.74.140 : ok=2 changed=1 unreachable=0 failed=0 192.168.74.140 : ok=2 changed=1 unreachable=0 failed=0
  7. 実行2回目 $ ansible-playbook -i hosts playbook.yml PLAY *************************************************************************** TASK [setup]

    ******************************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] TASK [Install Git] ************************************************************* ok: [192.168.74.140] ok: [192.168.74.141] ok: [192.168.74.142] PLAY RECAP ********************************************************************* 192.168.74.140 : ok=2 changed=0 unreachable=0 failed=0 192.168.74.140 : ok=2 changed=0 unreachable=0 failed=0 192.168.74.140 : ok=2 changed=0 unreachable=0 failed=0