今回学ぶこと

ディレクトリ構成

[~/sourcetree/AnsibleExam/nginx]$ tree
.
├── Vagrantfile
├── ansible.cfg
├── files
│     └── nginx
│            └── site-ansible.conf
├── hosts
├── nginx.retry
├── nginx.yml
└── templates
       └── index.html.j2

3 directories, 7 files

Playbook

https://github.com/kagyuu/AnsibleExam/blob/master/nginx/nginx.yml

- name: Configure nginx
  hosts: testserver
  become: True
  tasks:

    - name: Add repository
      yum_repository:
        name: epel
        description: EPEL YUM repo
        baseurl: http://download.fedoraproject.org/pub/epel/$releasever/$basearch/

    - name: Add gpg key of EPEL
      rpm_key: key=https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 state=present

    - name: Install nginx
      yum: name=nginx state=latest

    - name: copy nginx config file
      copy: src=files/nginx/site-ansible.conf dest=/etc/nginx/default.d/

    - name: Creates /ansible site directory
      file: path=/var/www/ansible state=directory owner=nginx group=nginx mode=0775

    - name: copy index.html
      template: src=templates/index.html.j2 dest=/var/www/ansible/index.html

    - name: start nginx
      service: name=nginx enabled=Yes state=started

実行結果

nginx.png

Ansible


添付ファイル: filenginx.png 1631件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2016-06-20 (月) 00:53:56 (3092d)
Short-URL: http://at-sushi.com/pukiwiki/index.php?cmd=s&k=5582cb6bc4
ISBN10
ISBN13
9784061426061