Advertisement
Guest User

Untitled

a guest
Sep 11th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.26 KB | None | 0 0
  1. - hosts: gluster
  2. become: yes
  3. gather_facts: yes
  4.  
  5. vars_files:
  6. - vars.yml
  7.  
  8. tasks:
  9.  
  10. - name: Generate /etc/hosts
  11. template:
  12. src=hosts.j2
  13. dest=/etc/hosts
  14.  
  15. - name: install gluster
  16. yum: name={{ item }} state=present
  17. with_items:
  18. - "centos-release-gluster"
  19.  
  20. - name: Install packages
  21. yum: name={{ item }} state=present
  22. with_items:
  23. - glusterfs-server
  24. - glusterfs-client
  25.  
  26. - name: enable gluster from startup
  27. command: systemctl enable glusterd.service
  28.  
  29. - name: start glusterd daemon
  30. command: systemctl start glusterd.service
  31.  
  32. - name: Ensure Gluster brick and mount directories exist.
  33. file: "path={{ item }} state=directory mode=0775"
  34. with_items:
  35. - "{{ gluster_brick_dir }}"
  36. - "{{ gluster_mount_dir }}"
  37.  
  38. - name: Configure Gluster volume.
  39. gluster_volume:
  40. state: present
  41. name: "{{ gluster_brick_name }}"
  42. brick: "{{ gluster_brick_dir }}"
  43. replicas: 3
  44. cluster: "{{ groups.gluster | join(',') }}"
  45. host: "{{ inventory_hostname }}"
  46. force: yes
  47. run_once: true
  48.  
  49. - name: Ensure Gluster volume is mounted.
  50. mount:
  51. name: "{{ gluster_mount_dir }}"
  52. src: "{{ inventory_hostname }}:/{{ gluster_brick_name }}"
  53. fstype: glusterfs
  54. opts: "defaults,_netdev"
  55. state: mounted
  56.  
  57. #install crushftp requirements
  58. - name: make sure java is installed
  59. yum:
  60. name: java
  61. state: latest
  62.  
  63. #Create an installation directory
  64. - name: Create installation directory
  65. file:
  66. path: /var/opt/CrushFTP7_PC
  67. state: directory
  68. mode: 0755
  69.  
  70. #Installation of crushftp
  71. - name: Copy Crushftp installer
  72. copy:
  73. src: /home/mikecali/Vagrant/crushftp-poc/package/CrushFTP7_PC.zip
  74. dest: /var/opt/
  75.  
  76. #make sure unzip is installed
  77. - name: Install unzip
  78. yum:
  79. name: unzip
  80. state: latest
  81.  
  82. - name: check if chrusftp directory exist
  83. stat:
  84. path: /var/opt/CrushFTP7_PC/
  85. register: dir_check
  86.  
  87.  
  88. #Install CrushFTP
  89. - name: Unzip the installer
  90. unarchive:
  91. src: /var/opt/CrushFTP7_PC.zip
  92. dest: /var/opt/
  93. copy: no
  94. become: yes
  95. when: dir_check.stat.isdir is defined and dir_chekc.stat.isdir
  96.  
  97. - name: change the file mode
  98. shell: chmod 700 /var/opt/CrushFTP7_PC/crushftp_init.sh
  99.  
  100. - name: verify if Crushftp is running
  101. shell: /var/opt/CrushFTP7_PC/crushftp_init.sh status
  102. register: cftp_status
  103.  
  104. #Start the crushftp
  105. - name: Start CrushFTP
  106. shell: sudo /var/opt/CrushFTP7_PC/crushftp_init.sh start
  107. become: yes
  108. when: cftp_status.stdout == "Shutting down CrushFTP"
  109.  
  110. #Generate Admin Password
  111. - name: Generate Admin Password
  112. shell: sudo /usr/bin/java -jar /var/opt/CrushFTP7_PC/CrushFTP.jar -a "crushadmin" "password"
  113. become: yes
  114.  
  115. #cluster installation
  116. - name: install clustering software
  117. yum: name={{ item }} state=present
  118. with_items:
  119. - "pcs"
  120. - "fence-agents-all"
  121.  
  122. - name: Determine if firewalld service masked
  123. command: systemctl is-enabled firewalld
  124. register: os_firewall_firewalld_masked_output
  125. changed_when: false
  126. failed_when: false
  127.  
  128. - name: Unmask firewalld service
  129. command: systemctl unmask firewalld
  130. when: os_firewall_firewalld_masked_output.stdout == "masked"
  131.  
  132. - name: Start and enable firewalld service
  133. service:
  134. name: firewalld
  135. state: restarted
  136. enabled: yes
  137. register: result
  138.  
  139.  
  140. - name: enable Firewall to allow HA traffic
  141. shell: firewall-cmd --permanent --add-service=high-availability
  142. when: result.changed
  143. ignore_errors: yes
  144.  
  145.  
  146. - name: add Firewall to allow HA traffic
  147. shell: firewall-cmd --add-service=high-availability
  148. when: result.changed
  149. ignore_errors: yes
  150.  
  151. - name: change password of hacluster
  152. user:
  153. name: hacluster
  154. update_password: always
  155. password: "hacluster"
  156.  
  157. - name: start the HA process
  158. service:
  159. name: pcsd.service
  160. state: started
  161.  
  162. - name: enable HA process
  163. service:
  164. name: pcsd.service
  165. enabled: yes
  166.  
  167. - name: Authorize cluster nodes
  168. pcs_auth: fqdn={{ hostvars[item]['ansible_fqdn'].split('.')[0] }} username={{ cluster_user }} password={{ cluster_user_pass }}
  169. run_once: true
  170. with_items: play_hosts
  171.  
  172. - name: Setup cluster
  173. command: >
  174. pcs cluster setup --name {{ cluster_name }} --start
  175. {% for host in play_hosts %}
  176. {% set short_name = hostvars[host]['ansible_fqdn'].split('.') %}
  177. {{ short_name[0] }}
  178. {% endfor %}
  179. run_once: true
  180. args:
  181. creates: /var/lib/pacemaker/cib/cib.xml
  182.  
  183. - name: Start cluster services on all nodes
  184. service: name={{ item }} state=started
  185. with_items:
  186. - pacemaker
  187. - corosync
  188.  
  189. - name: Enable cluster services on boot
  190. service: name={{ item }} enabled=yes
  191. when: cluster_enable_service == true
  192. with_items:
  193. - pacemaker
  194. - corosync
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement