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

Ansibleのベストプラクティス構成に従ったplaybook開発を一工夫する

yunano
September 14, 2015

 Ansibleのベストプラクティス構成に従ったplaybook開発を一工夫する

yunano

September 14, 2015
Tweet

More Decks by yunano

Other Decks in Technology

Transcript

  1. roles/ common/ # this hierarchy represents a “role” tasks/ #

    main.yml # <-- tasks file can include smaller files if warranted handlers/ # main.yml # <-- handlers file templates/ # <-- files for use with the template resource ntp.conf.j2 # <------- templates end in .j2 files/ # bar.txt # <-- files for use with the copy resource foo.sh # <-- script files for use with the script resource vars/ # main.yml # <-- variables associated with this role defaults/ # main.yml # <-- default lower priority variables for this role meta/ # main.yml # <-- role dependencies webtier/ # same kind of structure as “common” was above, done for the webtier role 4
  2. $ tree roles/role1 roles/role1 ├── defaults │ └── main.yml ├──

    files ├── handlers │ └── main.yml ├── meta │ └── main.yml ├── README.md ├── tasks │ └── main.yml ├── templates └── vars └── main.yml 8
  3. $ cat roles/role1/defaults/main.yml --- # defaults file for roles/role1 $

    cat roles/role1/handlers/main.yml --- # handlers file for roles/role1 $ cat roles/role1/tasks/main.yml --- # tasks file for roles/role1 $ cat roles/role1/vars/main.yml --- # vars file for roles/role1 9
  4. $ cat gather/%role1.yml --- # defaults/main.yml --- # defaults file

    for roles/role1 --- # handlers/main.yml --- # handlers file for roles/role1 --- # meta/main.yml (略) --- # tasks/main.yml --- # tasks file for roles/role1 --- # vars/main.yml --- # vars file for roles/role1 12
  5. $ vi gather/%role1.yml (前略) --- # tasks/main.yml --- # tasks

    file for roles/role1 - debug: var=key1 --- # vars/main.yml --- # vars file for roles/role1 key1: val1 14
  6. $ cat roles/role1/tasks/main.yml --- # tasks file for roles/role1 -

    debug: var=key1 $ cat roles/role1/vars/main.yml --- # vars file for roles/role1 key1: val1 16