├── ansible.cfg ├── vars └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── defaults └── main.yml ├── tasks ├── openstack.yml └── main.yml └── README.md /ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | roles_path = ../ 3 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for ansible-role-ceph-mon 3 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for ansible-role-ceph-mon 3 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: z 4 | description: ceph mon configure 5 | company: 6 | license: license (BSD, MIT) 7 | min_ansible_version: 1.8 8 | platforms: 9 | - name: EL 10 | versions: 11 | - 7 12 | categories: 13 | - cloud 14 | - system 15 | dependencies: [] 16 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for ansible-role-ceph-mon 3 | 4 | ceph_cluster_name: "ceph" 5 | ceph_fsid: "80605375-25ef-46b0-afee-97aff959463f" 6 | 7 | ceph_openstack_config: False 8 | ceph_pool_pg_num: 128 9 | openstack_glance_pool: "glance" 10 | openstack_cinder_pool: "cinder" 11 | openstack_nova_pool: "nova" 12 | openstack_cinder_backup_pool: "backups" 13 | openstack_keys: 14 | - { name: client.glance, value: "mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool={{ openstack_glance_pool }}'" } 15 | - { name: client.cinder, value: "mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool={{ openstack_cinder_pool }}, allow rwx pool={{ openstack_nova_pool }}, allow rx pool={{ openstack_glance_pool }}'" } 16 | - { name: client.cinder-backup, value: "mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool={{ openstack_cinder_backup_pool }}'" } 17 | -------------------------------------------------------------------------------- /tasks/openstack.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: create OpenStack pool. 3 | command: ceph osd pool create {{ item }} {{ ceph_pool_pg_num }} 4 | with_items: 5 | - "{{ openstack_glance_pool }}" 6 | - "{{ openstack_cinder_pool }}" 7 | - "{{ openstack_nova_pool }}" 8 | - "{{ openstack_cinder_backup_pool }}" 9 | ignore_errors: True 10 | changed_when: False 11 | when: inventory_hostname == groups['ceph-mon'][0] and cephx 12 | 13 | - name: create OpenStack keys. 14 | command: > 15 | ceph auth get-or-create {{ item.name }} {{ item.value }} -o /etc/ceph/ceph.{{ item.name }}.keyring 16 | creates=/etc/ceph/ceph.{{ item.name }}.keyring 17 | with_items: 18 | - "{{ openstack_keys }}" 19 | changed_when: False 20 | when: inventory_hostname == groups['ceph-mon'][0] and cephx 21 | 22 | - name: Copy ceph.conf to the ansible server. 23 | fetch: 24 | src: "{{ item }}" 25 | dest: "{{ inventory_dir }}/fetch/{{ ceph_fsid }}" 26 | when: inventory_hostname == groups['ceph-mon'][0] and cephx 27 | with_items: 28 | - /etc/ceph/ceph.conf 29 | 30 | - name: Copy OpenStack keys to the ansible server. 31 | fetch: 32 | src: /etc/ceph/ceph.{{ item.name }}.keyring 33 | dest: "{{ inventory_dir }}/fetch/{{ ceph_fsid }}" 34 | when: inventory_hostname == groups['ceph-mon'][0] and cephx 35 | with_items: 36 | - "{{ openstack_keys }}" 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Role Name: ceph-mon 2 | 3 | A Ansible Role for ceph mon configure. 4 | 5 | ## Requirements 6 | 7 | None. 8 | 9 | ## Role Variables 10 | 11 | ### `defaults/main.yml` 12 | 13 | * `ceph_cluster_name: "ceph"` 14 | * `ceph_fsid: "80605375-25ef-46b0-afee-97aff959463f"` 15 | * `ceph_openstack_config: False` 16 | * `ceph_pool_pg_num: 128` 17 | * `openstack_glance_pool: "glance"` 18 | * `openstack_cinder_pool: "cinder"` 19 | * `openstack_nova_pool: "nova"` 20 | * `openstack_cinder_backup_pool: "backups"` 21 | * `ceph_openstack_config:` 22 | ``` 23 | - { name: client.glance, value: "mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool={{ openstack_glance_pool }}'" } 24 | - { name: client.cinder, value: "mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool={{ openstack_cinder_pool }}, allow rwx pool={{ openstack_nova_pool }}, allow rx pool={{ openstack_glance_pool }}'" } 25 | - { name: client.cinder-backup, value: "mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool={{ openstack_cinder_backup_pool }}'" } 26 | ``` 27 | 28 | ## Dependencies 29 | 30 | None. 31 | 32 | ## Example Playbook 33 | 34 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 35 | 36 | - name: Install ceph mon. 37 | hosts: ceph-mon 38 | roles: 39 | - role: ansible-role-ceph-mon 40 | 41 | ## Author Information 42 | 43 | z 44 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for ansible-role-ceph-mon 3 | 4 | - name: Create monitor initial keyring. 5 | command: ceph-authtool /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} --create-keyring --name=mon. --add-key={{ monitor_secret }} --cap mon 'allow *' creates=/var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} 6 | 7 | - name: Set initial monitor key permissions. 8 | file: path=/var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} mode=0600 owner=root group=root 9 | 10 | - name: Create a default data directory (or directories) on the monitor host(s). 11 | file: path=/var/lib/ceph/mon/{{ ceph_cluster_name }}-{{ ansible_hostname }} state=directory owner=root group=root mode=0644 12 | 13 | - name: Populate the monitor daemon(s) with the monitor keyring. 14 | command: ceph-mon --cluster {{ ceph_cluster_name }} --mkfs -i {{ ansible_hostname }} --keyring /var/lib/ceph/tmp/keyring.mon.{{ ansible_hostname }} creates=/var/lib/ceph/mon/ceph-{{ ansible_hostname }}/keyring 15 | 16 | - name: Touch the done file. 17 | file: path=/var/lib/ceph/mon/{{ ceph_cluster_name }}-{{ ansible_hostname }}/done state=touch owner=root group=root mode=0644 18 | 19 | - name: Touch the sysvinit file. 20 | file: path=/var/lib/ceph/mon/{{ ceph_cluster_name }}-{{ ansible_hostname }}/sysvinit state=touch owner=root group=root mode=0644 21 | 22 | - name: Start and add that the monitor service to the init sequence. 23 | shell: | 24 | /etc/init.d/ceph start mon.{{ ansible_hostname }} 25 | sleep 15 26 | 27 | - name: Copy keys to the ansible server. 28 | fetch: 29 | src: "{{ item }}" 30 | dest: "{{ inventory_dir }}/fetch/{{ ceph_fsid }}" 31 | when: inventory_hostname == groups['ceph-mon'][0] and cephx 32 | with_items: 33 | - /etc/ceph/ceph.client.admin.keyring 34 | - /var/lib/ceph/bootstrap-osd/ceph.keyring 35 | - /var/lib/ceph/bootstrap-mds/ceph.keyring 36 | 37 | - name: Openstack config. 38 | include: openstack.yml 39 | when: ceph_openstack_config --------------------------------------------------------------------------------