Add more visibility for the 'when' statement.
Signed-off-by: leseb <seb@redhat.com>
- name: restart ceph mons
command: service ceph restart mon
- when: socket.rc == 0 and 'mons' in group_names
+ when:
+ socket.rc == 0 and
+ 'mons' in group_names
- name: restart ceph osds
command: service ceph restart osd
- when: socket.rc == 0 and 'osds' in group_names
+ when:
+ socket.rc == 0 and
+ 'osds' in group_names
- name: restart ceph osds on ubuntu
command: restart ceph-osd-all
- when: socket.rc == 0 and ansible_distribution == 'Ubuntu' and 'osds' in group_names
+ when:
+ socket.rc == 0 and
+ ansible_distribution == 'Ubuntu' and
+ 'osds' in group_names
- name: restart ceph mdss
command: service ceph restart mds
- when: socket.rc == 0 and 'mdss' in group_names
+ when:
+ socket.rc == 0 and
+ 'mdss' in group_names
- name: restart ceph rgws
command: /etc/init.d/radosgw restart
- when: socket.rc == 0 and 'rgws' in group_names
+ when:
+ socket.rc == 0 and
+ 'rgws' in group_names
apt_repository: >
repo="deb http://ceph.com/debian-{{ ceph_stable_release }}/ {{ ansible_lsb.codename }} main"
state=present
+ changed_when: false
when: ceph_stable
- name: add Ceph development repository
apt_repository: >
repo="deb http://gitbuilder.ceph.com/ceph-deb-{{ ansible_lsb.codename }}-x86_64-basic/ref/{{ ceph_dev_branch }} {{ ansible_lsb.codename }} main"
state=present
+ changed_when: false
when: ceph_dev
- name: add Inktank Ceph Enterprise repository
apt_repository: >
repo="deb file://{{ ceph_stable_ice_temp_path }} {{ ansible_lsb.codename }} main"
state=present
+ changed_when: false
when: ceph_stable_ice
- name: install Ceph
- name: add Ceph stable repository
yum: name=http://ceph.com/rpm-{{ ceph_stable_release }}/{{ ceph_stable_redhat_distro }}/noarch/ceph-release-1-0.{{ ceph_stable_redhat_distro|replace('rhel', 'el') }}.noarch.rpm
- register: repo_result
+ changed_when: false
when: ceph_stable
- failed_when: repo_result.rc > 1
- changed_when: repo_result.rc == 0
- name: add Ceph development repository
yum: name=http://gitbuilder.ceph.com/ceph-rpm-{{ ceph_dev_redhat_distro }}-x86_64-basic/ref/{{ ceph_dev_branch }}/noarch/ceph-release-1-0.{{ ceph_stable_redhat_distro }}.noarch.rpm
- register: repo_result
+ changed_when: false
when: ceph_dev
- failed_when: repo_result.rc > 1
- changed_when: repo_result.rc == 0
- name: add Inktank Ceph Enterprise repository
template: >
- name: check for a Ceph socket
shell: "stat /var/run/ceph/*.asok > /dev/null 2>&1"
+ changed_when: false
ignore_errors: true
register: socket
- changed_when: False
- name: generate cluster UUID
shell: >
uuidgen | tee fetch/ceph_cluster_uuid.conf
creates=fetch/ceph_cluster_uuid.conf
connection: local
- sudo: false
register: cluster_uuid
+ sudo: false
- name: read cluster UUID if it already exists
command: >
cat fetch/ceph_cluster_uuid.conf
removes=fetch/ceph_cluster_uuid.conf
connection: local
- sudo: false
+ changed_when: false
register: cluster_uuid
- changed_when: False
+ sudo: false
- include: check-mandatory-vars.yml
---
- name: disable OSD directory parsing by updatedb
command: updatedb -e /var/lib/ceph
+ changed_when: false
ignore_errors: true
- changed_when: False
- name: disable transparent hugepage
command: "echo never > /sys/kernel/mm/transparent_hugepage/enabled"
- when: disable_transparent_hugepage
+ changed_when: false
ignore_errors: true
- changed_when: False
+ when: disable_transparent_hugepage
- name: disable swap
command: swapoff -a
- when: disable_swap
+ changed_when: false
ignore_errors: true
- changed_when: False
+ when: disable_swap
- name: apply OS tuning
sysctl: >
with_items:
- kmod-libceph-{{ ceph_stable_ice_kmod }}.rpm
- kmod-rbd-{{ ceph_stable_ice_kmod }}.rpm
- when: ceph_stable_ice and ansible_os_family == 'RedHat'
+ when:
+ ceph_stable_ice and
+ ansible_os_family == 'RedHat'
- name: stat extracted ICE repo files
stat: >
shell: >
tar -xzf ICE-{{ ceph_stable_ice_version }}-{{ ceph_stable_ice_distro }}.tar.gz
chdir={{ ceph_stable_ice_temp_path }}
- when: ceph_stable_ice and repo_exist.stat.exists == False
- changed_when: False
+ changed_when: false
+ when:
+ ceph_stable_ice and
+ repo_exist.stat.exists == False
- name: move ICE extracted packages
shell: "mv {{ ceph_stable_ice_temp_path }}/ceph/*/* {{ ceph_stable_ice_temp_path }}"
- when: ceph_stable_ice and repo_exist.stat.exists == False
- changed_when: False
+ changed_when: false
+ when:
+ ceph_stable_ice and
+ repo_exist.stat.exists == False
- /var/lib/ceph/bootstrap-mds/ceph.keyring
- name: install docker-py
- pip: name=docker-py version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
+ pip: >
+ name=docker-py
+ version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
- name: stat for Ceph config and keys
stat: >
path={{ item }}
with_items: ceph_config_keys
+ ignore_errors: true
register: statconfig
- ignore_errors: True
- name: try to fetch Ceph config and keys
copy: >
command: >
ceph --cluster ceph --name client.bootstrap-mds --keyring /var/lib/ceph/bootstrap-mds/ceph.keyring auth get-or-create mds.{{ ansible_hostname }} osd 'allow rwx' mds 'allow' mon 'allow profile mds' -o /var/lib/ceph/mds/ceph-{{ ansible_hostname }}/keyring
creates=/var/lib/ceph/mds/ceph-{{ ansible_hostname }}/keyring
+ changed_when: false
when: cephx
- changed_when: False
- name: set MDS key permissions
file: >
with_items:
- done
- upstart
+ changed_when: false
when: ansible_distribution == "Ubuntu"
- name: activate metadata server with sysvinit
with_items:
- done
- sysvinit
+ changed_when: false
when: ansible_distribution != "Ubuntu"
- name: start and add that the metadata service to the init sequence (Ubuntu)
state=started
enabled=yes
args="id={{ ansible_hostname }}"
+ changed_when: false
when: ansible_distribution == "Ubuntu"
- name: start and add that the metadata service to the init sequence
state=started
enabled=yes
args=mds
+ changed_when: false
when: ansible_distribution != "Ubuntu"
command: >
ceph auth get-or-create client.restapi osd 'allow *' mon 'allow *' -o /etc/ceph/ceph.client.restapi.keyring
creates=/etc/ceph/ceph.client.restapi.keyring
- when: cephx and restapi
- changed_when: False
+ changed_when: false
+ when:
+ cephx and
+ restapi
- include: openstack_config.yml
- when: openstack_config and cephx
+ when:
+ openstack_config and
+ cephx
- name: find Ceph keys
shell: ls -1 /etc/ceph/*.keyring
+ changed_when: false
register: ceph_keys
when: cephx
- changed_when: False
- name: set keys permissions
file: >
src={{ item }}
dest=fetch/{{ fsid }}/{{ item }}
flat=yes
- when: cephx
with_items:
- "{{ ceph_keys.stdout_lines }}"
- /var/lib/ceph/bootstrap-osd/ceph.keyring
- /var/lib/ceph/bootstrap-rgw/ceph.keyring
- /var/lib/ceph/bootstrap-mds/ceph.keyring
+ when: cephx
- name: drop in a motd script to report status when logging in
copy: >
with_items:
- cephfs_data
- cephfs_metadata
- changed_when: False
+ changed_when: false
when: not {{ ceph_version.stdout | version_compare('0.84', '<') }}
- name: create Ceph Filesystem
command: ceph fs new {{ cephfs }} {{ cephfs_metadata }} {{ cephfs_data }}
- changed_when: False
+ changed_when: false
when: not {{ ceph_version.stdout | version_compare('0.84', '<') }}
- /etc/ceph/ceph.mon.keyring
- name: install docker-py
- pip: name=docker-py version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
+ pip: >
+ name=docker-py
+ version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
- name: stat for Ceph config and keys
stat: >
path={{ item }}
with_items: ceph_config_keys
+ ignore_errors: true
register: statconfig
- ignore_errors: True
- name: try to fetch Ceph config and keys
copy: >
when: not ceph_containerized_deployment
- include: create_mds_filesystems.yml
- when: not ceph_containerized_deployment and mds
+ when:
+ not ceph_containerized_deployment and
+ mds
- include: secure_cluster.yml
- when: secure_cluster and not ceph_containerized_deployment
- tags: secure_cluster
+ when:
+ secure_cluster and
+ not ceph_containerized_deployment
- include: docker.yml
when: ceph_containerized_deployment
- "{{ openstack_cinder_pool }}"
- "{{ openstack_nova_pool }}"
- "{{ openstack_cinder_backup_pool }}"
- ignore_errors: True
- changed_when: False
+ changed_when: false
+ ignore_errors: true
- name: create OpenStack keys
command: >
ceph auth get-or-create {{ item.name }} {{ item.value }} -o /etc/ceph/ceph.{{ item.name }}.keyring
creates=/etc/ceph/ceph.{{ item.name }}.keyring
with_items: openstack_keys
- changed_when: False
+ changed_when: false
- done
- upstart
when: ansible_distribution == "Ubuntu"
- changed_when: False
+ changed_when: false
- name: activate monitor with sysvinit
file: >
- name: get Ceph monitor version
shell: ceph daemon mon."{{ ansible_hostname }}" version | cut -d '"' -f 4 | cut -f 1,2 -d '.'
+ changed_when: false
register: ceph_version
- changed_when: False
- parted.results
- ispartition.results
- devices
- when: item.0.rc == 0 and item.1.rc != 0
- ignore_errors: True
- changed_when: False
+ changed_when: false
+ ignore_errors: true
+ when:
+ item.0.rc == 0 and
+ item.1.rc != 0
# NOTE (leseb): this task is for partitions because we don't explicitly use a partition.
- name: activate OSD(s) when device is a partition
with_together:
- ispartition.results
- devices
+ changed_when: false
+ ignore_errors: true
when: item.0.rc == 0
- ignore_errors: True
- changed_when: False
- include: osd_fragment.yml
when: crush_location
# NOTE (leseb): current behavior of ceph-disk is to fail when the device is mounted "stderr: ceph-disk: Error: Device is mounted: /dev/sdb1"
# the return code is 1, which makes sense, however ideally if ceph-disk will detect a ceph partition
# it should exist we rc=0 and don't do anything unless we do something like --force
-# As as a final word, I prefer to keep the partition check instead of running ceph-disk prepare with "ignore_errors: True"
+# As as a final word, I prefer to keep the partition check instead of running ceph-disk prepare with "ignore_errors: true"
# I believe it's safer
- name: check if the device is a partition or a disk
shell: "echo '{{ item }}' | egrep '/dev/(([a-z]{3,4}[0-9]$)|(cciss/c[0-9]{1}d[0-9]{1}p[0-9]$))'"
- ignore_errors: true
with_items: devices
+ changed_when: false
+ ignore_errors: true
register: ispartition
- changed_when: False
- name: if partition named 'ceph' exists
shell: "parted --script {{ item }} print | egrep -sq '^ 1.*ceph'"
- ignore_errors: True
with_items: devices
+ changed_when: false
+ ignore_errors: true
register: parted
- changed_when: False
- /var/lib/ceph/bootstrap-osd/ceph.keyring
- name: install docker-py
- pip: name=docker-py version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
+ pip: >
+ name=docker-py
+ version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
- name: stat for Ceph config and keys
stat: >
path={{ item }}
with_items: ceph_config_keys
+ ignore_errors: true
register: statconfig
- ignore_errors: True
- name: try to fetch Ceph config and keys
copy: >
# failed, this is why we check if the device is a partition too.
- name: automatic prepare OSD disk(s) without partitions
command: ceph-disk prepare "/dev/{{ item.key }}"
- when: ansible_devices is defined and item.value.removable == "0" and item.value.partitions|count == 0 and journal_collocation and osd_auto_discovery
- ignore_errors: True
- with_dict: ansible_devices
+ ignore_errors: true
register: prepared_osds
+ with_dict: ansible_devices
+ when:
+ ansible_devices is defined and
+ item.value.removable == "0" and
+ item.value.partitions|count == 0 and
+ journal_collocation and
+ osd_auto_discovery
- name: manually Prepare OSD disk(s)
command: "ceph-disk prepare {{ item.2 }}"
+ ignore_errors: true
+ with_together:
+ - parted.results
+ - ispartition.results
+ - devices
when:
item.0.rc != 0 and
item.1.rc != 0 and
journal_collocation and not
osd_auto_discovery
- ignore_errors: True
- with_together:
- - parted.results
- - ispartition.results
- - devices
- include: activate_osds.yml
# since Ansible will sequential process the loop
- name: prepare OSD disk(s)
command: "ceph-disk prepare {{ item }}"
- when: osd_directory
with_items: osd_directories
- changed_when: False
+ changed_when: false
+ when: osd_directory
- name: activate OSD(s)
command: "ceph-disk activate {{ item }}"
with_items: osd_directories
- changed_when: False
+ changed_when: false
- name: start and add that the OSD service to the init sequence
service: >
- name: get OSD path
shell: "df | grep {{ item }} | awk '{print $6}'"
with_items: devices
- register: osd_path
+ changed_when: false
ignore_errors: true
- changed_when: False
+ register: osd_path
- name: get OSD id
command: cat {{ item.stdout }}/whoami
- register: osd_id
with_items: osd_path.results
+ changed_when: false
ignore_errors: true
- changed_when: False
+ register: osd_id
- name: create a Ceph fragment and assemble directory
file: >
- name: copy ceph.conf for assembling
command: cp /etc/ceph/ceph.conf /etc/ceph/ceph.d/
- changed_when: False
+ changed_when: false
- name: assemble OSD sections
assemble: >
# failed, this is why we check if the device is a partition too.
- name: prepare OSD disk(s)
command: "ceph-disk prepare {{ item.2 }} {{ item.3 }}"
- when: item.0.rc != 0 and
- item.1.rc != 0 and
- raw_multi_journal
- ignore_errors: True
with_together:
- parted.results
- ispartition.results
- devices
- raw_journal_devices
- changed_when: False
+ changed_when: false
+ ignore_errors: true
+ when:
+ item.0.rc != 0 and
+ item.1.rc != 0 and
+ raw_multi_journal
- include: activate_osds.yml
# ensures that the device will get successfully prepared.
- name: erasing partitions and labels from OSD disk(s)
command: ceph-disk zap {{ item }}
- when: zap_devices and (journal_collocation or raw_multi_journal)
with_items: devices
- changed_when: False
+ changed_when: false
+ when:
+ zap_devices and
+ (journal_collocation or raw_multi_journal)
- name: erasing partitions and labels from the journal device(s)
command: ceph-disk zap {{ item }}
- when: zap_devices and raw_multi_journal
with_items: raw_journal_devices
- changed_when: False
+ changed_when: false
+ when:
+ zap_devices and
+ raw_multi_journal
- /var/lib/ceph/bootstrap-rgw/ceph.keyring
- name: install docker-py
- pip: name=docker-py version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
+ pip: >
+ name=docker-py
+ version=1.1.0 # https://github.com/ansible/ansible-modules-core/issues/1227
- name: stat for Ceph config and keys
stat: >
path={{ item }}
with_items: ceph_config_keys
+ ignore_errors: true
register: statconfig
- ignore_errors: True
- name: try to fetch Ceph config and keys
copy: >
- deb http://archive.ubuntu.com/ubuntu {{ ansible_lsb.codename }} multiverse
- deb http://archive.ubuntu.com/ubuntu {{ ansible_lsb.codename }}-updates multiverse
- deb http://security.ubuntu.com/ubuntu {{ ansible_lsb.codename }}-security multiverse
- when: ansible_lsb.codename in ['precise'] and not http_100_continue
+ when:
+ ansible_lsb.codename in ['precise'] and not
+ http_100_continue
# NOTE (leseb): disable the repo when we are using the Ceph repo for 100-continue packages
- name: disable multiverse repo for Precise
- deb http://archive.ubuntu.com/ubuntu {{ ansible_lsb.codename }} multiverse
- deb http://archive.ubuntu.com/ubuntu {{ ansible_lsb.codename }}-updates multiverse
- deb http://security.ubuntu.com/ubuntu {{ ansible_lsb.codename }}-security multiverse
- when: ansible_lsb.codename in ['precise'] and http_100_continue
+ when:
+ ansible_lsb.codename in ['precise'] and
+ http_100_continue
# NOTE (leseb): needed for Ubuntu 14.04 to have access to libapache2-mod-fastcgi if 100-continue isn't being used
- name: enable multiverse repo for Trusty
command: "apt-add-repository multiverse"
- when: ansible_lsb.codename in ['trusty'] and not http_100_continue
- changed_when: False
+ changed_when: false
+ when:
+ ansible_lsb.codename in ['trusty'] and not
+ http_100_continue
# NOTE (leseb): disable the repo when we are using the Ceph repo for 100-continue packages
- name: disable multiverse repo for Trusty
command: "apt-add-repository -r multiverse"
- when: ansible_lsb.codename in ['trusty'] and http_100_continue
- changed_when: False
+ changed_when: false
+ when:
+ ansible_lsb.codename in ['trusty'] and
+ http_100_continue
# NOTE (leseb): if using 100-continue, add Ceph dev key
- name: install the Ceph development repository key
- apache2.2-bin
- apache2.2-common
- libapache2-mod-fastcgi
- when: purge_default_apache.changed or purge_ceph_apache.changed
+ when:
+ purge_default_apache.changed or
+ purge_ceph_apache.changed
- name: install Apache and fastcgi
apt: >
with_items:
- a2enmod rewrite
- a2enmod fastcgi
- changed_when: False
+ changed_when: false
- name: install Rados Gateway vhost
template: >
with_items:
- a2ensite rgw.conf
- a2dissite *default
- ignore_errors: True
+ changed_when: false
+ ignore_errors: true
notify:
- restart apache2
- changed_when: False
- name: install s3gw.fcgi script
template: >
- name: add special fastcgi repository
command: rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
- changed_when: False
+ changed_when: false
- name: install Apache and fastcgi
yum: >
- name: disable default site
shell: sed -i "s/^[^+#]/#/g" /etc/httpd/conf.d/welcome.conf
- changed_when: False
+ changed_when: false
notify:
- restart apache2
when: not ceph_containerized_deployment
- include: install_redhat.yml
- when: ansible_os_family == 'RedHat' and radosgw_frontend == 'apache' and not ceph_containerized_deployment
+ when:
+ ansible_os_family == 'RedHat' and
+ radosgw_frontend == 'apache' and not
+ ceph_containerized_deployment
- include: install_debian.yml
- when: ansible_os_family == 'Debian' and radosgw_frontend == 'apache' and not ceph_containerized_deployment
+ when:
+ ansible_os_family == 'Debian' and
+ radosgw_frontend == 'apache' and not
+ ceph_containerized_deployment
- name: install Rados Gateway
apt: >
pkg=radosgw
state=present
update_cache=yes
- when: ansible_os_family == 'Debian' and not ceph_containerized_deployment
+ when:
+ ansible_os_family == 'Debian' and not
+ ceph_containerized_deployment
- name: install Rados Gateway
yum: >
name=ceph-radosgw
state=present
- when: ansible_os_family == 'RedHat' and not ceph_containerized_deployment
+ when:
+ ansible_os_family == 'RedHat' and not
+ ceph_containerized_deployment
- include: openstack-keystone.yml
when: radosgw_keystone
command: >
ceph --cluster ceph --name client.bootstrap-rgw --keyring /var/lib/ceph/bootstrap-rgw/ceph.keyring auth get-or-create client.rgw.{{ ansible_hostname }} osd 'allow rwx' mon 'allow rw' -o /var/lib/ceph/radosgw/ceph-rgw.{{ ansible_hostname }}/keyring
creates=/var/lib/ceph/radosgw/ceph-rgw.{{ ansible_hostname }}/keyring
+ changed_when: false
when: cephx
- changed_when: False
- name: set RGW key permissions
file: >
with_items:
- done
- upstart
+ changed_when: false
when: ansible_distribution == "Ubuntu"
# NOTE (leseb): if we don't perform this check Ansible will start multiple instance of radosgw
- name: check if RGW is started
command: /etc/init.d/radosgw status
+ changed_when: false
+ ignore_errors: true
register: rgwstatus
- ignore_errors: True
- name: start RGW
command: /etc/init.d/radosgw start
- when: rgwstatus.rc != 0 and ansible_distribution != "Ubuntu" and ansible_os_family != 'RedHat'
+ when:
+ rgwstatus.rc != 0 and
+ ansible_distribution != "Ubuntu" and
+ ansible_os_family != 'RedHat'
- name: start RGW
- service: name=radosgw-all state=started
+ service: >
+ name=radosgw-all
+ state=started
when: ansible_distribution == "Ubuntu"
- name: start RGW
- service: name=ceph-radosgw state=started
+ service: >
+ name=ceph-radosgw
+ state=started
when: ansible_os_family == 'RedHat'
- name: check if Ceph REST API is already started
shell: "pgrep ceph-rest-api"
+ ignore_errors: true
register: restapi_status
- ignore_errors: True
- name: start Ceph REST API
shell: "nohup ceph-rest-api &"
+ changed_when: false
when: restapi_status.rc != 0
- changed_when: False
with_items:
- done
- upstart
+ changed_when: false
when: ansible_distribution == "Ubuntu"
- changed_when: False
- name: activate Ceph REST API with sysvinit
file: >