�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
d
e f d � � YZ d � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: gluster_peer
short_description: Attach/Detach peers to/from the cluster
description:
- Create or diminish a GlusterFS trusted storage pool. A set of nodes can be
added into an existing trusted storage pool or a new storage pool can be
formed. Or, nodes can be removed from an existing trusted storage pool.
version_added: "2.6"
author: Sachidananda Urs (@sac)
options:
state:
choices: ["present", "absent"]
default: "present"
description:
- Determines whether the nodes should be attached to the pool or
removed from the pool. If the state is present, nodes will be
attached to the pool. If state is absent, nodes will be detached
from the pool.
required: true
nodes:
description:
- List of nodes that have to be probed into the pool.
required: true
force:
type: bool
default: "false"
description:
- Applicable only while removing the nodes from the pool. gluster
will refuse to detach a node from the pool if any one of the node
is down, in such cases force can be used.
requirements:
- GlusterFS > 3.2
notes:
- This module does not support check mode.
s�
- name: Create a trusted storage pool
gluster_peer:
state: present
nodes:
- 10.0.1.5
- 10.0.1.10
- name: Delete a node from the trusted storage pool
gluster_peer:
state: absent
nodes:
- 10.0.1.10
- name: Delete a node from the trusted storage pool by force
gluster_peer:
state: absent
nodes:
- 10.0.0.1
force: true
t
( t
AnsibleModule( t LooseVersiont Peerc B` s, e Z d � Z d � Z d � Z d � Z RS( c C` s{ | | _ | j j d | _ | j j d | _ | j j d t � | _ t d d d d d d � | _ d | _ d | _
d S( Nt statet nodest glustert LANGt Ct LC_ALLt LC_MESSAGESt ( t modulet paramsR R
t get_bin_patht Truet
glustercmdt dictt langt actiont force( t selfR ( ( sR /usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_peer.pyt __init__T s c C` s� | j s | j j d d � n | j j j d � r: d n d | _ | j d k r| | j | j � | _ d | _ d | _ n d | _ | j � d S( Nt msgs nodes list cannot be emptyR R t presentt probet detach(
R
R t fail_jsonR t getR R t get_to_be_probed_hostsR t call_peer_commands( R ( ( sR /usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_peer.pyt gluster_peer_ops] s $ c
C` s� | j d d d g } | j j | d | j �\ } } } g t d | j d � d � D] } | j d � d j � ^ qV } y | j d � Wn t k
r� n Xg | D] } | | k r� | ^ q� } | S( Nt poolt lists
--mode=scriptt environ_updates
i s t localhost(
R R t run_commandR t filtert Nonet splitt stript removet
ValueError(
R t hostst peercmdt rct outputt errt linet peers_in_clustert hostt hosts_to_be_probed( ( sR /usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_peer.pyR% j s ?
c C` s� i } d | d <t | d <x� | j D]� } | j d | j | d g } | j ra | j | j � n | j j | d | j �\ } } } | r� | | d <| | d <| j j | � q$ d | k s� d | k r� | d c t O<q$ t
| d <q$ W| j j | � d S(
NR R t changedt peers
--mode=scriptR* R5 s already in peers localhost not needed( t FalseR
R R R t appendR R, R R# R t exit_json( R t resultt nodeR4 R5 t outR7 ( ( sR /usr/lib/python2.7/site-packages/ansible/modules/storage/glusterfs/gluster_peer.pyR&