2014-09-05 03:14:11 +08:00
|
|
|
---
|
2015-07-17 00:42:12 +08:00
|
|
|
- name: generate monitor initial keyring
|
syntax: change local_action syntax
Use a nicer syntax for `local_action` tasks.
We used to have oneliner like this:
```
local_action: wait_for port=22 host={{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }} state=started delay=10 timeout=500 }}
```
The usual syntax:
```
local_action:
module: wait_for
port: 22
host: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
state: started
delay: 10
timeout: 500
```
is nicer and kind of way to keep consistency regarding the whole
playbook.
This also fix a potential issue about missing quotation :
```
Traceback (most recent call last):
File "/tmp/ansible_wQtWsi/ansible_module_command.py", line 213, in <module>
main()
File "/tmp/ansible_wQtWsi/ansible_module_command.py", line 185, in main
rc, out, err = module.run_command(args, executable=executable, use_unsafe_shell=shell, encoding=None, data=stdin)
File "/tmp/ansible_wQtWsi/ansible_modlib.zip/ansible/module_utils/basic.py", line 2710, in run_command
File "/usr/lib64/python2.7/shlex.py", line 279, in split
return list(lex) File "/usr/lib64/python2.7/shlex.py", line 269, in next
token = self.get_token()
File "/usr/lib64/python2.7/shlex.py", line 96, in get_token
raw = self.read_token()
File "/usr/lib64/python2.7/shlex.py", line 172, in read_token
raise ValueError, "No closing quotation"
ValueError: No closing quotation
```
writing `local_action: shell echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf`
can cause trouble because it's complaining with missing quotes, this fix solves this issue.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1510555
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
2018-01-31 16:23:28 +08:00
|
|
|
local_action:
|
|
|
|
module: shell
|
2018-06-21 16:08:39 +08:00
|
|
|
python -c "import os ; import struct ; import time; import base64 ; key = os.urandom(16) ; header = struct.pack('<hiih',1,int(time.time()),0,len(key)) ; print(base64.b64encode(header + key).decode())" | tee {{ fetch_directory }}/monitor_keyring.conf
|
syntax: change local_action syntax
Use a nicer syntax for `local_action` tasks.
We used to have oneliner like this:
```
local_action: wait_for port=22 host={{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }} state=started delay=10 timeout=500 }}
```
The usual syntax:
```
local_action:
module: wait_for
port: 22
host: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
state: started
delay: 10
timeout: 500
```
is nicer and kind of way to keep consistency regarding the whole
playbook.
This also fix a potential issue about missing quotation :
```
Traceback (most recent call last):
File "/tmp/ansible_wQtWsi/ansible_module_command.py", line 213, in <module>
main()
File "/tmp/ansible_wQtWsi/ansible_module_command.py", line 185, in main
rc, out, err = module.run_command(args, executable=executable, use_unsafe_shell=shell, encoding=None, data=stdin)
File "/tmp/ansible_wQtWsi/ansible_modlib.zip/ansible/module_utils/basic.py", line 2710, in run_command
File "/usr/lib64/python2.7/shlex.py", line 279, in split
return list(lex) File "/usr/lib64/python2.7/shlex.py", line 269, in next
token = self.get_token()
File "/usr/lib64/python2.7/shlex.py", line 96, in get_token
raw = self.read_token()
File "/usr/lib64/python2.7/shlex.py", line 172, in read_token
raise ValueError, "No closing quotation"
ValueError: No closing quotation
```
writing `local_action: shell echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf`
can cause trouble because it's complaining with missing quotes, this fix solves this issue.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1510555
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
2018-01-31 16:23:28 +08:00
|
|
|
creates: "{{ fetch_directory }}/monitor_keyring.conf"
|
2015-07-17 20:06:25 +08:00
|
|
|
register: monitor_keyring
|
2016-02-04 19:36:46 +08:00
|
|
|
become: false
|
2016-02-25 21:57:50 +08:00
|
|
|
when: cephx
|
2015-07-17 00:42:12 +08:00
|
|
|
|
|
|
|
- name: read monitor initial keyring if it already exists
|
syntax: change local_action syntax
Use a nicer syntax for `local_action` tasks.
We used to have oneliner like this:
```
local_action: wait_for port=22 host={{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }} state=started delay=10 timeout=500 }}
```
The usual syntax:
```
local_action:
module: wait_for
port: 22
host: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
state: started
delay: 10
timeout: 500
```
is nicer and kind of way to keep consistency regarding the whole
playbook.
This also fix a potential issue about missing quotation :
```
Traceback (most recent call last):
File "/tmp/ansible_wQtWsi/ansible_module_command.py", line 213, in <module>
main()
File "/tmp/ansible_wQtWsi/ansible_module_command.py", line 185, in main
rc, out, err = module.run_command(args, executable=executable, use_unsafe_shell=shell, encoding=None, data=stdin)
File "/tmp/ansible_wQtWsi/ansible_modlib.zip/ansible/module_utils/basic.py", line 2710, in run_command
File "/usr/lib64/python2.7/shlex.py", line 279, in split
return list(lex) File "/usr/lib64/python2.7/shlex.py", line 269, in next
token = self.get_token()
File "/usr/lib64/python2.7/shlex.py", line 96, in get_token
raw = self.read_token()
File "/usr/lib64/python2.7/shlex.py", line 172, in read_token
raise ValueError, "No closing quotation"
ValueError: No closing quotation
```
writing `local_action: shell echo {{ fsid }} | tee {{ fetch_directory }}/ceph_cluster_uuid.conf`
can cause trouble because it's complaining with missing quotes, this fix solves this issue.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1510555
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
2018-01-31 16:23:28 +08:00
|
|
|
local_action:
|
|
|
|
module: command
|
|
|
|
cat {{ fetch_directory }}/monitor_keyring.conf
|
|
|
|
removes: "{{ fetch_directory }}/monitor_keyring.conf"
|
2015-07-17 00:42:12 +08:00
|
|
|
changed_when: false
|
2015-07-17 20:06:25 +08:00
|
|
|
register: monitor_keyring
|
2016-02-04 19:36:46 +08:00
|
|
|
become: false
|
2017-10-25 22:53:34 +08:00
|
|
|
check_mode: no
|
2016-02-25 21:57:50 +08:00
|
|
|
when: cephx
|
2015-07-17 00:42:12 +08:00
|
|
|
|
2015-05-16 00:27:41 +08:00
|
|
|
- name: create monitor initial keyring
|
2018-04-04 22:22:36 +08:00
|
|
|
ceph_key:
|
|
|
|
name: mon.
|
|
|
|
state: present
|
|
|
|
dest: "/var/lib/ceph/tmp/"
|
|
|
|
secret: "{{ monitor_secret }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
caps:
|
|
|
|
mon: allow *
|
|
|
|
import_key: False
|
2016-02-25 21:57:50 +08:00
|
|
|
when: cephx
|
2014-09-05 03:14:11 +08:00
|
|
|
|
2016-02-02 22:10:24 +08:00
|
|
|
- name: set initial monitor key permissions
|
2015-11-17 23:10:02 +08:00
|
|
|
file:
|
2018-04-04 22:22:36 +08:00
|
|
|
path: "/var/lib/ceph/tmp/{{ cluster }}.mon..keyring"
|
2017-01-20 17:14:35 +08:00
|
|
|
owner: "ceph"
|
|
|
|
group: "ceph"
|
|
|
|
mode: "0600"
|
2016-02-25 21:57:50 +08:00
|
|
|
when: cephx
|
2015-11-17 23:10:02 +08:00
|
|
|
|
2017-06-30 16:17:23 +08:00
|
|
|
- name: create (and fix ownership of) monitor directory
|
2015-11-17 23:10:02 +08:00
|
|
|
file:
|
2016-03-29 21:37:31 +08:00
|
|
|
path: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}
|
2015-11-17 23:10:02 +08:00
|
|
|
state: directory
|
2017-01-20 17:14:35 +08:00
|
|
|
owner: "ceph"
|
|
|
|
group: "ceph"
|
|
|
|
mode: "0755"
|
2017-06-30 16:17:23 +08:00
|
|
|
recurse: true
|
2015-11-17 23:10:02 +08:00
|
|
|
|
2018-10-11 03:24:22 +08:00
|
|
|
- name: set_fact client_admin_ceph_authtool_cap
|
2017-09-15 06:48:53 +08:00
|
|
|
set_fact:
|
2018-04-04 22:22:36 +08:00
|
|
|
client_admin_ceph_authtool_cap:
|
|
|
|
mon: allow *
|
|
|
|
osd: allow *
|
|
|
|
mds: allow
|
|
|
|
mgr: allow *
|
2017-07-24 22:00:06 +08:00
|
|
|
when:
|
|
|
|
- cephx
|
|
|
|
- admin_secret != 'admin_secret'
|
|
|
|
|
2017-07-05 17:07:00 +08:00
|
|
|
- name: create custom admin keyring
|
2018-04-04 22:22:36 +08:00
|
|
|
ceph_key:
|
|
|
|
name: client.admin
|
|
|
|
state: present
|
|
|
|
secret: "{{ admin_secret }}"
|
|
|
|
auid: 0
|
|
|
|
caps: "{{ client_admin_ceph_authtool_cap }}"
|
|
|
|
import_key: False
|
|
|
|
cluster: "{{ cluster }}"
|
2017-07-05 17:07:00 +08:00
|
|
|
register: create_custom_admin_secret
|
|
|
|
when:
|
|
|
|
- cephx
|
|
|
|
- admin_secret != 'admin_secret'
|
|
|
|
|
|
|
|
- name: set ownership of admin keyring
|
|
|
|
file:
|
|
|
|
path: /etc/ceph/{{ cluster }}.client.admin.keyring
|
|
|
|
state: file
|
|
|
|
owner: 'ceph'
|
|
|
|
group: 'ceph'
|
2018-06-25 21:12:56 +08:00
|
|
|
mode: "{{ ceph_keyring_permissions }}"
|
2017-07-05 17:07:00 +08:00
|
|
|
when:
|
|
|
|
- cephx
|
|
|
|
- admin_secret != 'admin_secret'
|
|
|
|
|
|
|
|
- name: import admin keyring into mon keyring
|
2018-04-04 22:22:36 +08:00
|
|
|
command: ceph-authtool /var/lib/ceph/tmp/{{ cluster }}.mon..keyring --import-keyring /etc/ceph/{{ cluster }}.client.admin.keyring
|
2017-07-05 17:07:00 +08:00
|
|
|
when:
|
2017-08-22 20:10:10 +08:00
|
|
|
- not create_custom_admin_secret.get('skipped')
|
2017-07-05 17:07:00 +08:00
|
|
|
- cephx
|
|
|
|
- admin_secret != 'admin_secret'
|
|
|
|
|
2017-01-20 17:14:35 +08:00
|
|
|
- name: ceph monitor mkfs with keyring
|
2018-04-04 22:22:36 +08:00
|
|
|
command: ceph-mon --cluster {{ cluster }} --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }} --keyring /var/lib/ceph/tmp/{{ cluster }}.mon..keyring
|
2015-11-17 23:10:02 +08:00
|
|
|
args:
|
2016-03-29 21:37:31 +08:00
|
|
|
creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring
|
2016-02-25 21:57:50 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- cephx
|
2014-09-05 03:14:11 +08:00
|
|
|
|
2017-01-20 17:14:35 +08:00
|
|
|
- name: ceph monitor mkfs without keyring
|
2016-06-06 22:22:20 +08:00
|
|
|
command: ceph-mon --cluster {{ cluster }} --setuser ceph --setgroup ceph --mkfs -i {{ monitor_name }} --fsid {{ fsid }}
|
2016-02-25 21:57:50 +08:00
|
|
|
args:
|
2016-03-29 21:37:31 +08:00
|
|
|
creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/store.db
|
2016-02-25 21:57:50 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- not cephx
|