LoginSignup
0
1

More than 5 years have passed since last update.

CentOSにIDCFのcloudstack-apiをansibleでセットアップ

Posted at

前提

  • CentOS6.8 (IDCFクラウドテンプレート)
  • Ansibleタスクはroleとして作成してPlaybookから読み込む形とした
  • IDCFクラウドのリージョンは東日本
  • Ansibleのinventoryファイルは適当に用意

ファイル構成

┣ files
┃ ┗ .idcfrc
┣ roles
┃ ┗ install-cloudstack-api
┃    ┗ tasks
┃       ┗ main.yml
┣ hosts
┗ playbook.yml

files/.idcfrc

.idcfrc
[account]
host=https://compute.jp-east.idcfcloud.com/client/api
api_key=[IDCFクラウド管理画面からコピペ]
secret_key=[IDCFクラウド管理画面からコピペ]

roles/install-cloudstack-api/tasks/main.yml

main.yml
- name: "cloudstack-apiインストール状態確認"
  stat: path=/usr/bin/cloudstack-api
  register: installed

- name: "cloudstack-apiインストール要否判定"
  set_fact:
    need_to_install: "{{ installed.stat.exists == False }}"

- name: "pythonz インストール"
  shell: "curl -kL https://raw.github.com/saghul/pythonz/master/pythonz-install | bash"
  when: need_to_install

- name: "ez_setup インストール"
  shell: "wget https://github.com/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python"
  when: need_to_install

- name: "setuptools 更新"
  shell: "pip install setuptools --upgrade"
  when: need_to_install

- name: "pip インストール"
  shell: "easy_install pip"
  when: need_to_install

- name: "関連パッケージ インストール"
  yum: 
    name={{ item }}
    state=present
  with_items:
    - python-devel
    - gcc
    - libxslt-devel
  when: need_to_install

- name: "IDCF cloudstack-api インストール(数分かかります)"
  shell: "pip install git+https://github.com/idcf/cloudstack-api"
  when: need_to_install

- name: "API設定ファイル を設置"
  copy: src=.idcfrc dest=/root/.idcfrc owner=root group=root

playbook.yml

- hosts: ciservers
  roles:
    - install-cloudstack-api

実行

ansible-playbook -i hosts playbook.yml

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1