├── vars └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── templates ├── hosts.j2 ├── ceph.repo.j2 └── ceph.conf.j2 ├── defaults └── main.yml ├── tasks └── main.yml └── README.md /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for ansible-role-ceph-common 3 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for ansible-role-ceph-common 3 | 4 | - name: restart ceph 5 | service: name=ceph state=restarted 6 | 7 | - name: restart network 8 | service: name=network state=restarted 9 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: z 4 | description: ceph common 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 | -------------------------------------------------------------------------------- /templates/hosts.j2: -------------------------------------------------------------------------------- 1 | # {{ ansible_managed }} 2 | 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 3 | ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 4 | 5 | # ceph 6 | {% for host in groups['all'] %} 7 | {% if hostvars[host]['sp_ip'] is defined %} 8 | {{ hostvars[host]['sp_ip'] }} {{ hostvars[host]['host_name'] }} 9 | {% endif %} 10 | {% endfor %} 11 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for ansible-role-ceph-common 3 | ceph_repo_enable: False 4 | ceph_repo_baseurl: "http://download.ceph.com/rpm-firefly/el7/" 5 | 6 | ceph_cluster_name: "ceph" 7 | ceph_fsid: "80605375-25ef-46b0-afee-97aff959463f" 8 | ceph_mon_members: "{{ hostvars[groups['ceph-mon'][0]]['ansible_hostname'] }}, {{ hostvars[groups['ceph-mon'][1]]['ansible_hostname'] }}, {{ hostvars[groups['ceph-mon'][2]]['ansible_hostname'] }}" 9 | cep_mon_host: "10.0.2.31,10.0.2.32,10.0.2.33" 10 | ceph_public_network: "10.0.2.0/24" 11 | ceph_cluster_network: "10.0.2.0/24" 12 | ceph_log_path: "/var/log" 13 | -------------------------------------------------------------------------------- /templates/ceph.repo.j2: -------------------------------------------------------------------------------- 1 | [Ceph] 2 | name=Ceph packages for $basearch 3 | #baseurl=http://ceph.com/rpm-firefly/el7/$basearch 4 | baseurl={{ ceph_repo_baseurl }}/$basearch 5 | enabled=1 6 | gpgcheck=0 7 | type=rpm-md 8 | gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc 9 | 10 | [Ceph-noarch] 11 | name=Ceph noarch packages 12 | #baseurl=http://ceph.com/rpm-firefly/el7/noarch 13 | baseurl={{ ceph_repo_baseurl }}/noarch 14 | enabled=1 15 | gpgcheck=0 16 | type=rpm-md 17 | gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc 18 | 19 | [ceph-source] 20 | name=Ceph source packages 21 | #baseurl=http://ceph.com/rpm-firefly/el7/SRPMS 22 | baseurl={{ ceph_repo_baseurl }}/SRPMS 23 | enabled=0 24 | gpgcheck=1 25 | type=rpm-md 26 | gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc 27 | -------------------------------------------------------------------------------- /templates/ceph.conf.j2: -------------------------------------------------------------------------------- 1 | [global] 2 | fsid = {{ ceph_fsid }} 3 | mon_initial_members = {{ ceph_mon_members }} 4 | mon_host = {{ cep_mon_host }} 5 | auth_cluster_required = cephx 6 | auth_service_required = cephx 7 | auth_client_required = cephx 8 | filestore_xattr_use_omap = true 9 | osd_pool_default_size = 3 10 | public_network = {{ ceph_public_network }} 11 | cluster_network = {{ ceph_cluster_network }} 12 | mon_allow_pool_delete = false 13 | osd_max_backfills = 1 14 | osd_recovery_max_active=1 15 | osd_recovery_max_single_start=1 16 | 17 | # log 18 | log_file = {{ ceph_log_path }}/ceph/$cluster-$name.log 19 | mon_cluster_log_file = {{ ceph_log_path }}/ceph/$cluster.log 20 | #log_to_syslog = true 21 | #err_to_syslog = true 22 | #clog_to_syslog = true 23 | #mon_cluster_log_to_syslog = true 24 | mon_osd_nearfull_ratio = 0.65 25 | mon_osd_full_ratio = 0.75 26 | 27 | [osd] 28 | osd_journal_size = 20480 29 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # tasks file for ansible-role-ceph-common 3 | 4 | - name: Prepare hosts file for name resolution. 5 | template: src=hosts.j2 dest=/etc/hosts 6 | 7 | - name: Stop firewall. 8 | service: name=firewalld state=stopped enabled=no 9 | 10 | - name: configure repo. 11 | template: src=ceph.repo.j2 dest=/etc/yum.repos.d/ceph.repo 12 | when: ceph_repo_enable 13 | 14 | - name: Install pre-requisite packages. 15 | yum: name={{ item }} state=installed 16 | with_items: 17 | - snappy 18 | - leveldb 19 | - gdisk 20 | - python-argparse 21 | - gperftools-libs 22 | 23 | - name: Install ceph. 24 | yum: name=ceph state=installed 25 | 26 | - name: Generate Ceph configuration file. 27 | template: src=ceph.conf.j2 dest=/etc/ceph/ceph.conf 28 | notify: restart ceph 29 | 30 | - name: Ceph log config. 31 | shell: | 32 | mkdir -p {{ ceph_log_path }}/ceph 33 | sed -i "s#/var/log#{{ ceph_log_path }}#g" /etc/logrotate.d/ceph -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Role Name: ceph-common 2 | 3 | A Ansible role for ceph common configure. 4 | 5 | ## Requirements 6 | 7 | None. 8 | 9 | ## Role Variables 10 | 11 | ### `defaults/main.yml'` 12 | 13 | * `ceph_repo_enable: False` 14 | * `ceph_repo_baseurl: "http://download.ceph.com/rpm-firefly/el7/"` 15 | * `ceph_cluster_name: "ceph"` 16 | * `ceph_fsid: "80605375-25ef-46b0-afee-97aff959463f"` 17 | * `ceph_mon_members: "{{ hostvars[groups['ceph-mon'][0]]['ansible_hostname'] }}, {{ hostvars[groups['ceph-mon'][1]]['ansible_hostname'] }}, {{ hostvars[groups['ceph-mon'][2]]['ansible_hostname'] }}"` 18 | * `cep_mon_host: "10.0.2.31,10.0.2.32,10.0.2.33"` 19 | * `ceph_public_network: "10.0.2.0/24"` 20 | * `ceph_cluster_network: "10.0.3.0/24"` 21 | 22 | ## Dependencies 23 | 24 | None. 25 | 26 | ## Example Playbook 27 | 28 | Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: 29 | 30 | - name: Ceph Node Base Configure. 31 | hosts: ceph 32 | roles: 33 | - role: ansible-role-ceph-common 34 | 35 | ## Author Information 36 | 37 | z. 38 | --------------------------------------------------------------------------------