]> git.apps.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
fog-server: Create role 374/head
authorDavid Galloway <dgallowa@redhat.com>
Wed, 24 Jan 2018 18:47:15 +0000 (13:47 -0500)
committerDavid Galloway <dgallowa@redhat.com>
Wed, 24 Jan 2018 19:12:52 +0000 (14:12 -0500)
Signed-off-by: David Galloway <dgallowa@redhat.com>
fog-server.yml [new file with mode: 0644]
roles/fog-server/README.rst [new file with mode: 0644]
roles/fog-server/defaults/main.yml [new file with mode: 0644]
roles/fog-server/tasks/install.yml [new file with mode: 0644]
roles/fog-server/tasks/main.yml [new file with mode: 0644]
roles/fog-server/tasks/update.yml [new file with mode: 0644]
roles/fog-server/templates/temp_settings.j2 [new file with mode: 0644]

diff --git a/fog-server.yml b/fog-server.yml
new file mode 100644 (file)
index 0000000..9479c23
--- /dev/null
@@ -0,0 +1,10 @@
+---
+- hosts: fog_server
+  roles:
+    - fog-server
+  become: true
+  vars_prompt:
+    - name: "fog_force"
+      prompt: "\nWARNING: It is not safe to run this role on a running FOG server that\nhas or may have scheduled tasks.\nDo you want to forcefully install/update/restart FOG? (yes|no)"
+      default: "no"
+      private: no
diff --git a/roles/fog-server/README.rst b/roles/fog-server/README.rst
new file mode 100644 (file)
index 0000000..2d73fec
--- /dev/null
@@ -0,0 +1,48 @@
+fog-server
+==========
+
+This role can be used to install and update a FOG_ server.  It has been minimally tested on Ubuntu 16.04 and CentOS 7.4.
+
+Notes
++++++
+
+* You must manually configure firewall, SELinux, and repos on RHEL/CentOS/Fedora.
+* This role assumes the ``sudo`` group already exists and has passwordless sudo access.
+* We'd recommend running in verbose mode to see shell output.  It can take around 10 minutes for the Install and Update tasks to complete.
+
+Variables
++++++++++
+
++-----------------------------------------------------------------------------------------------------------------------------------------------+
+| **Required Variables**                                                                                                                        |
++----------------------------+------------------------------------------------------------------------------------------------------------------+
+| ``fog_user: fog``          | Name for user account to be created on the system.  The application will be run from this user's home directory. |
++----------------------------+------------------------------------------------------------------------------------------------------------------+
+| ``fog_branch: master``     | Branch of FOG to checkout and install.  Defaults to master but could be set to ``working`` for bleeding edge.    |
++----------------------------+------------------------------------------------------------------------------------------------------------------+
+| ``fog_dhcp_server: false`` | Set to ``true`` if you want FOG to install and configure the host as a DHCP server.                              |
++----------------------------+------------------------------------------------------------------------------------------------------------------+
+
+**Optional Variables**
+
+If none of these are set, the FOG defaults will be used.  For simplicity's sake, the variables have been named after the variables in fogsettings_.  Read the official documentation for a description of what each does.
+
+* fog_ipaddress
+* fog_interface
+* fog_submask
+* fog_routeraddress
+* fog_plainrouter
+* fog_dnsaddress
+* fog_password
+* fog_startrange (Required if ``fog_dhcp_server: true``)
+* fog_endrange (Required if ``fog_dhcp_server: true``)
+* fog_snmysqluser
+* fog_snmysqlpass
+* fog_snmysqlhost
+* fog_images_path
+* fog_docroot
+* fog_webroot
+* fog_httpproto
+
+.. _FOG: https://fogproject.org/
+.. _fogsettings: https://wiki.fogproject.org/wiki/index.php?title=.fogsettings
diff --git a/roles/fog-server/defaults/main.yml b/roles/fog-server/defaults/main.yml
new file mode 100644 (file)
index 0000000..aca4e87
--- /dev/null
@@ -0,0 +1,4 @@
+---
+fog_user: fog
+fog_branch: master
+fog_dhcp_server: false
diff --git a/roles/fog-server/tasks/install.yml b/roles/fog-server/tasks/install.yml
new file mode 100644 (file)
index 0000000..eed8a3a
--- /dev/null
@@ -0,0 +1,12 @@
+---
+- name: Clone FOG
+  git:
+    repo: https://github.com/FOGProject/fogproject.git
+    dest: "/home/{{ fog_user }}/fog"
+    version: "{{ fog_branch }}"
+
+- name: Install FOG
+  shell: "sudo ./installfog.sh -Y -f /home/{{ fog_user }}/temp_settings"
+  args:
+    chdir: "/home/{{ fog_user }}/fog/bin"
+  become_user: "{{ fog_user }}"
diff --git a/roles/fog-server/tasks/main.yml b/roles/fog-server/tasks/main.yml
new file mode 100644 (file)
index 0000000..a647a31
--- /dev/null
@@ -0,0 +1,48 @@
+---
+- name: Ensure a user for FOG
+  user:
+    name: "{{ fog_user }}"
+    shell: /bin/bash
+    group: sudo
+    append: yes
+    createhome: yes
+
+- name: Ensure a path for FOG
+  file:
+    path: "/home/{{ fog_user}}/fog"
+    owner: "{{ fog_user }}"
+    state: directory
+
+- name: Write temp settings/answer file for FOG
+  template:
+    src: temp_settings.j2
+    dest: "/home/{{ fog_user }}/temp_settings"
+    owner: "{{ fog_user }}"
+
+# Unattended upgrades (of mysql specifically) will break FOG
+# https://forums.fogproject.org/topic/10006/ubuntu-is-fog-s-enemy
+- name: Make sure unattended-upgrades is not installed
+  apt:
+    name: unattended-upgrades
+    state: absent
+  when: ansible_os_family == "Debian"
+
+- name: Check if FOG is already installed
+  stat:
+    path: /opt/fog
+  register: fog_path_found
+
+- import_tasks: install.yml
+  when:
+    - fog_path_found.stat.exists == false
+    - fog_force == "yes"
+
+- import_tasks: update.yml
+  when:
+    - fog_path_found.stat.exists == true
+    - fog_force == "yes"
+
+- name: Clean up temp settings/answer file for FOG
+  file:
+    path: "/home/{{ fog_user }}/temp_settings"
+    state: absent
diff --git a/roles/fog-server/tasks/update.yml b/roles/fog-server/tasks/update.yml
new file mode 100644 (file)
index 0000000..9478859
--- /dev/null
@@ -0,0 +1,13 @@
+---
+- name: Update FOG checkout
+  git:
+    repo: https://github.com/FOGProject/fogproject.git
+    dest: "/home/{{ fog_user }}/fog"
+    version: "{{ fog_branch }}"
+    update: yes
+
+- name: Update FOG
+  shell: "sudo ./installfog.sh -Y -f /home/{{ fog_user }}/temp_settings"
+  args:
+    chdir: "/home/{{ fog_user }}/fog/bin"
+  become_user: "{{ fog_user }}"
diff --git a/roles/fog-server/templates/temp_settings.j2 b/roles/fog-server/templates/temp_settings.j2
new file mode 100644 (file)
index 0000000..3b99d05
--- /dev/null
@@ -0,0 +1,99 @@
+{% if fog_ipaddress is defined %}
+ipaddress='{{ fog_ipaddress }}'
+{% else %}
+ipaddress='{{ ansible_default_ipv4.address }}'
+{% endif %}
+{% if fog_interface is defined %}
+interface='{{ fog_interface }}'
+{% else %}
+interface='{{ ansible_default_ipv4.alias }}'
+{% endif %}
+{% if fog_submask is defined %}
+submask='{{ fog_submask }}'
+{% else %}
+submask='{{ ansible_default_ipv4.netmask }}'
+{% endif %}
+{% if fog_routeraddress is defined %}
+routeraddress='{{ fog_routeraddress }}'
+{% else %}
+routeraddress='{{ ansible_default_ipv4.gateway }}'
+{% endif %}
+{% if fog_plainrouter is defined %}
+plainrouter='{{ fog_plainrouter }}'
+{% else %}
+plainrouter=''
+{% endif %}
+{% if fog_dnsaddress is defined %}
+dnsaddress='{{ fog_dnsaddress }}'
+{% else %}
+dnsaddress=''
+{% endif %}
+username='{{ fog_user }}'
+{% if fog_password is defined %}
+password='{{ fog_password }}'
+{% endif %}
+{% if ansible_os_family == "RedHat" %}
+osid='1'
+{% elif ansible_os_family == "Debian" %}
+osid='2'
+{% elif ansible_os_family == "Archlinux" %}
+osid='3'
+{% endif %}
+{% if fog_dhcp_server == true %}
+dodhcp='Y'
+bldhcp='1'
+startrange='{{ fog_startrange }}'
+endrange='{{ fog_endrange }}'
+{% else %}
+dodhcp='N'
+bldhcp='0'
+startrange=''
+endrange=''
+{% endif %}
+dhcpd='isc-dhcp-server'
+blexports='1'
+installtype='N'
+{% if fog_snmysqluser is defined %}
+snmysqluser='{{ fog_snmysqluser }}'
+{% else %}
+snmysqluser='root'
+{% endif %}
+{% if fog_snmysqlpass is defined %}
+snmysqlpass='{{ fog_snmysqlpass }}'
+{% else %}
+snmysqlpass=''
+{% endif %}
+{% if fog_snmysqlhost is defined %}
+snmysqlhost='{{ fog_snmysqlhost }}'
+{% else %}
+snmysqlhost='localhost'
+{% endif %}
+installlang='0'
+{% if fog_images_path is defined %}
+storageLocation='{{ fog_images_path }}'
+{% else %}
+storageLocation='/images'
+{% endif %}
+fogupdateloaded=1
+{% if fog_docroot is defined %}
+docroot='{{ fog_docroot }}'
+{% else %}
+docroot='/var/www/html/'
+{% endif %}
+{% if fog_webroot is defined %}
+webroot='{{ fog_webroot }}'
+{% else %}
+webroot='/fog/'
+{% endif %}
+caCreated='yes'
+bootfilename='undionly.kpxe'
+noTftpBuild=''
+notpxedefaultfile=''
+sslpath='/opt/fog/snapins/ssl/'
+backupPath=''
+sslprivkey='/opt/fog/snapins/ssl//.srvprivate.key'
+{% if fog_httpproto is defined %}
+httpproto='{{ fog_httpproto }}'
+{% else %}
+httpproto='http'
+{% endif %}