├── ansible.cfg ├── vars └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── tasks ├── node_setup.yml ├── master_setup.yml ├── main.yml └── secondary_storage.yml ├── defaults └── main.yml ├── test.yml └── README.md /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | roles_path = ../ 3 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for ansible-role-cloudstack-management 3 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for ansible-role-cloudstack-management 3 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: z@zstack.net 4 | description: Install Apache Cloudstack Management. 5 | company: 6 | license: license (BSD, MIT) 7 | min_ansible_version: 1.8 8 | platforms: 9 | - name: EL 10 | versions: 11 | - 6 12 | - 7 13 | categories: 14 | - cloud 15 | dependencies: [] 16 | -------------------------------------------------------------------------------- /tasks/node_setup.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for cloudstack node management setup 3 | 4 | - name: Cloudstack setup databases 5 | command: /usr/bin/cloudstack-setup-databases {{ cloudstack_mysql_user }}:{{ cloudstack_mysql_password }}@{{ cloudstack_mysql_host }} -m {{ cloudstack_seckey }} -k {{ cloudstack_seckey }} 6 | 7 | - name: Setup CloudStack manager 8 | command: /usr/bin/cloudstack-setup-management 9 | -------------------------------------------------------------------------------- /tasks/master_setup.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for cloudstack master management setup 3 | 4 | - name: Cloudstack setup databases 5 | command: /usr/bin/cloudstack-setup-databases {{ cloudstack_mysql_user }}:{{ cloudstack_mysql_password }}@{{ cloudstack_mysql_host }} --deploy-as=root:{{ cloudstack_mysql_root_password }} -m {{ cloudstack_seckey }} -k {{ cloudstack_seckey }} 6 | 7 | - name: Setup CloudStack manager 8 | command: /usr/bin/cloudstack-setup-management 9 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for ansible-role-cloudstack-management 3 | 4 | - name: Install Requires Packages for Cloudstack Management 5 | yum: name={{ item }} state=present 6 | with_items: 7 | - java-1.7.0-openjdk 8 | 9 | - name: Ensure CloudStack Management packages are installed 10 | yum: name=cloudstack-management state=present 11 | 12 | - name: Ensure CloudStack Usage packages are installed 13 | yum: name=cloudstack-usage state=present 14 | when: cloudstack_usage 15 | 16 | - name: Setup Master Cloudstack Management 17 | include: master_setup.yml 18 | when: cloudstack_master 19 | 20 | - name: Setup Secondary Storage And Systemvm Template 21 | include: secondary_storage.yml 22 | when: cloudstack_master 23 | 24 | - name: Setup Node Cloudstack Management 25 | include: node_setup.yml 26 | when: cloudstack_node 27 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for ansible-role-cloudstack-management 3 | 4 | cloudstack_master: false 5 | cloudstack_node: false 6 | cloudstack_usage: false 7 | 8 | cloudstack_seckey: "password" 9 | 10 | cloudstack_mysql_host: "127.0.0.1" 11 | cloudstack_mysql_port: 3306 12 | cloudstack_mysql_user: "cloud" 13 | cloudstack_mysql_password: "cloud" 14 | cloudstack_mysql_root_password: "password" 15 | 16 | cloudstack_templates_url: "http://cloudstack.apt-get.eu/systemvm/4.4" 17 | cloudstack_nfs_mount_path: "/mnt/secondary" 18 | cloudstack_nfs_export_ip: "127.0.0.1" 19 | cloudstack_nfs_export_path: "/data/secondary" 20 | 21 | cloudstack_tmplt_diskspace: 5120000 22 | cloudstack_systemvm_vmware: 23 | enable: false 24 | template_name: "systemvm64template-4.4.1-7-vmware.ova" 25 | 26 | cloudstack_systemvm_kvm: 27 | enable: false 28 | template_name: "systemvm64template-4.4.1-7-kvm.qcow2.bz2" 29 | -------------------------------------------------------------------------------- /test.yml: -------------------------------------------------------------------------------- 1 | - name: Install Cloudstack Management master 2 | hosts: cloudstack_master 3 | vars: 4 | cloudstack_repo: "http://cloudstack.apt-get.eu/centos" 5 | cloudstack_ver: "4.4" 6 | cloudstack_master: true 7 | cloudstack_usage: true 8 | cloudstack_mysql_host: "127.0.0.1" 9 | cloudstack_mysql_port: 3306 10 | cloudstack_mysql_user: "cloud" 11 | cloudstack_mysql_password: "cloud" 12 | cloudstack_mysql_root_password: "password" 13 | cloudstack_templates_url: "http://cloudstack.apt-get.eu/systemvm/4.4" 14 | cloudstack_seckey: "password" 15 | cloudstack_nfs_export_ip: "127.0.0.1" 16 | cloudstack_tmplt_diskspace: 1020000 17 | cloudstack_systemvm_kvm: 18 | enable: true 19 | template_name: "systemvm64template-4.4.1-7-kvm.qcow2.bz2" 20 | roles: 21 | - ansible-role-cloudstack-common 22 | - ansible-role-cloudstack-management 23 | 24 | - name: Install Cloudstack Management node 25 | hosts: cloudstack_node 26 | vars: 27 | cloudstack_repo: "http://cloudstack.apt-get.eu/centos" 28 | cloudstack_ver: "4.4" 29 | cloudstack_node: true 30 | cloudstack_mysql_host: "127.0.0.1" 31 | cloudstack_mysql_port: 3306 32 | cloudstack_mysql_user: "cloud" 33 | cloudstack_mysql_password: "cloud" 34 | roles: 35 | - ansible-role-cloudstack-common 36 | - ansible-role-cloudstack-management 37 | -------------------------------------------------------------------------------- /tasks/secondary_storage.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for secondary storage setup 3 | 4 | - name: Ensure secondary storage mount exists 5 | file: path={{ cloudstack_nfs_mount_path }} state=directory 6 | 7 | - name: Ensure secondary storage is mounted 8 | mount: name={{ cloudstack_nfs_mount_path }} src={{ cloudstack_nfs_export_ip }}:{{ cloudstack_nfs_export_path }} fstype=nfs state=mounted opts=nolock 9 | 10 | - name: Fix cloud install sys tmplt DISKSPACE 11 | lineinfile: > 12 | dest="/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt" 13 | regexp="{{ item.regexp }}" 14 | line="{{ item.line }}" 15 | state=present 16 | with_items: 17 | - { regexp: "DISKSPACE=5120000", line: "DISKSPACE={{ cloudstack_tmplt_diskspace }}" } 18 | 19 | - name: Register VMware Systemvm Template 20 | command: /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m {{ cloudstack_nfs_mount_path }} -u {{ cloudstack_templates_url }}/{{ cloudstack_systemvm_vmware.template_name }} -h vmware -F -s {{ cloudstack_seckey }} 21 | when: cloudstack_systemvm_vmware.enable 22 | 23 | - name: Register KVM Systemvm Template 24 | command: /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m {{ cloudstack_nfs_mount_path }} -u {{ cloudstack_templates_url }}/{{ cloudstack_systemvm_kvm.template_name }} -h kvm -F -s {{ cloudstack_seckey }} 25 | when: cloudstack_systemvm_kvm.enable 26 | 27 | - name: Ensure secondary storage is unmounted 28 | command: umount {{ cloudstack_nfs_mount_path }} 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: cloudstack-management 2 | 3 | Ansible role that Install Apache Cloudstack Management. 4 | 5 | ## Requirements 6 | 7 | None 8 | 9 | ## Role Variables 10 | 11 | ### `defaults/main.yml` 12 | 13 | * `cloudstack_master: false` 14 | * `cloudstack_node: false` 15 | * `cloudstack_usage: false` 16 | * `cloudstack_mysql_host: "127.0.0.1"` 17 | * `cloudstack_mysql_port: 3306` 18 | * `cloudstack_mysql_user: "cloud"` 19 | * `cloudstack_mysql_password: "cloud"` 20 | * `cloudstack_mysql_root_password: "password"` 21 | 22 | * `cloudstack_templates_url: "http://127.0.0.1/cloudstack/systemvm"` 23 | * `cloudstack_seckey: "password"` 24 | * `cloudstack_nfs_mount_path: "/mnt/secondary"` 25 | * `cloudstack_nfs_export_ip: "127.0.0.1"` 26 | * `cloudstack_nfs_export_path: "/data/secondary"` 27 | * `cloudstack_tmplt_diskspace: 5120000` 28 | - 如果管理端系统分区小于5120000 kilobytes,需要修改此参数. 29 | 30 | * `cloudstack_systemvm_vmware:` 31 | ``` 32 | enable: false 33 | template_name: "systemvm64template-4.4.1-7-vmware.ova" 34 | ``` 35 | 36 | * `cloudstack_systemvm_kvm:` 37 | ``` 38 | enable: false 39 | template_name: "systemvm64template-4.4.1-7-kvm.qcow2.bz2" 40 | ``` 41 | 42 | ## Dependencies 43 | 44 | - cloudstack-common 45 | 46 | ## Example Playbook 47 | 48 | - name: Install Cloudstack Management master 49 | hosts: servers 50 | vars: 51 | cloudstack_repo: "http://cloudstack.apt-get.eu/centos" 52 | cloudstack_ver: "4.4" 53 | cloudstack_master: true 54 | cloudstack_usage: true 55 | cloudstack_mysql_host: "127.0.0.1" 56 | cloudstack_mysql_port: 3306 57 | cloudstack_mysql_user: "cloud" 58 | cloudstack_mysql_password: "cloud" 59 | cloudstack_mysql_root_password: "password" 60 | cloudstack_templates_url: http://cloudstack.apt-get.eu/systemvm/4.4" 61 | cloudstack_seckey: "password" 62 | cloudstack_nfs_export_ip: "127.0.0.1" 63 | cloudstack_nfs_export_path: "/data/secondary" 64 | cloudstack_tmplt_diskspace: 1020000 65 | cloudstack_systemvm_kvm: 66 | enable: true 67 | template_name: "systemvm64template-4.4.1-7-kvm.qcow2.bz2" 68 | roles: 69 | - cloudstack-common 70 | - cloudstack-management 71 | 72 | - name: Install Cloudstack Management node 73 | hosts: servers 74 | vars: 75 | cloudstack_repo: "http://cloudstack.apt-get.eu/centos" 76 | cloudstack_ver: "4.4" 77 | cloudstack_node: true 78 | cloudstack_mysql_host: "127.0.0.1" 79 | cloudstack_mysql_port: 3306 80 | cloudstack_mysql_user: "cloud" 81 | cloudstack_mysql_password: "cloud" 82 | roles: 83 | - cloudstack-common 84 | - cloudstack-management 85 | 86 | ## License 87 | 88 | MIT / BSD 89 | 90 | ## Author Information 91 | 92 | z@zstack.net 93 | --------------------------------------------------------------------------------