mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
Startup (#85)
* move local_facts, test for it, cp if necess * got os wrong -- not OS * change /etc/*release, vars/filenames * add os_ver * add os_ver to iiab.env * remove uuid generation for local_facts * next * delete debugging lines * fetch the uuid, and put it in ini file * be more specific about uuid * need braces in set_fact * hyphen in OS-version * go back to OS.yml based upon os_ver * remove debug * oops VERSION_ID->OS_VER * issure error message when OS not in case statement
This commit is contained in:
parent
0f9d25ab7c
commit
dfe68e63fa
16 changed files with 66 additions and 36 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
vars_files:
|
vars_files:
|
||||||
- vars/default_vars.yml
|
- vars/default_vars.yml
|
||||||
- vars/{{ ansible_distribution }}.yml
|
- vars/{{ ansible_local.local_facts.os_ver }}.yml
|
||||||
- vars/local_vars.yml
|
- vars/local_vars.yml
|
||||||
- /etc/iiab/config_vars.yml
|
- /etc/iiab/config_vars.yml
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
vars_files:
|
vars_files:
|
||||||
- vars/default_vars.yml
|
- vars/default_vars.yml
|
||||||
- vars/{{ ansible_distribution }}.yml
|
- vars/{{ ansible_local.local_facts.os_ver }}.yml
|
||||||
- vars/local_vars.yml
|
- vars/local_vars.yml
|
||||||
- /etc/iiab/config_vars.yml
|
- /etc/iiab/config_vars.yml
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
vars_files:
|
vars_files:
|
||||||
- vars/default_vars.yml
|
- vars/default_vars.yml
|
||||||
- vars/{{ ansible_distribution }}.yml
|
- vars/{{ ansible_local.local_facts.os_ver }}.yml
|
||||||
- vars/local_vars.yml
|
- vars/local_vars.yml
|
||||||
- /etc/iiab/config_vars.yml
|
- /etc/iiab/config_vars.yml
|
||||||
|
|
||||||
|
|
2
iiab.yml
2
iiab.yml
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
vars_files:
|
vars_files:
|
||||||
- vars/default_vars.yml
|
- vars/default_vars.yml
|
||||||
- vars/{{ ansible_distribution}}.yml
|
- vars/{{ ansible_local.local_facts.os_ver}}.yml
|
||||||
- vars/local_vars.yml
|
- vars/local_vars.yml
|
||||||
- /etc/iiab/config_vars.yml
|
- /etc/iiab/config_vars.yml
|
||||||
|
|
||||||
|
|
|
@ -30,5 +30,7 @@
|
||||||
value: '{{ ansible_local["local_facts"]["iiab_commit"] }}'
|
value: '{{ ansible_local["local_facts"]["iiab_commit"] }}'
|
||||||
- option: 'install_date'
|
- option: 'install_date'
|
||||||
value: '{{ ansible_date_time["iso8601"] }}'
|
value: '{{ ansible_date_time["iso8601"] }}'
|
||||||
|
- option: 'Universal Unique ID (uuid)'
|
||||||
|
value: '{{ uuid }}'
|
||||||
- option: 'install_xo'
|
- option: 'install_xo'
|
||||||
value: '{{ xo_model }}'
|
value: '{{ xo_model }}'
|
||||||
|
|
|
@ -3,11 +3,44 @@
|
||||||
is_F18: True
|
is_F18: True
|
||||||
when: ansible_distribution_release == "based on Fedora 18" or ansible_distribution_version == "18"
|
when: ansible_distribution_release == "based on Fedora 18" or ansible_distribution_version == "18"
|
||||||
|
|
||||||
|
- name: abort if the OS is not supported
|
||||||
|
debug: msg="{{ ansible_local.local_facts.os }} Operating System is not supported"
|
||||||
|
when: ansible_local.local_facts.os_ver == "OS_not_supported"
|
||||||
|
|
||||||
|
# there may be a stop execution, but I did not find it
|
||||||
|
- pause:
|
||||||
|
when: ansible_local.local_facts.os_ver == "OS_not_supported"
|
||||||
|
|
||||||
- name: get the uuidgen program
|
- name: get the uuidgen program
|
||||||
package: name=uuid-runtime
|
package: name=uuid-runtime
|
||||||
state=present
|
state=present
|
||||||
when: is_debuntu
|
when: is_debuntu
|
||||||
|
|
||||||
|
- name: Test for UUID file
|
||||||
|
stat: path=/etc/iiab/uuid
|
||||||
|
register: uuid_file
|
||||||
|
|
||||||
|
- name: Create folder to hold uuid
|
||||||
|
file: path=/etc/iiab state=directory
|
||||||
|
when: not uuid_file.stat.exists
|
||||||
|
|
||||||
|
- name: If no uuid exists, create one
|
||||||
|
shell: uuidgen
|
||||||
|
register: uuid_response
|
||||||
|
when: not uuid_file.stat.exists
|
||||||
|
|
||||||
|
- name: Put the uuid in place
|
||||||
|
shell: echo {{ uuid_response.stdout_lines[0] }} > /etc/iiab/uuid
|
||||||
|
when: not uuid_file.stat.exists
|
||||||
|
|
||||||
|
- name: get the uuid
|
||||||
|
command: cat /etc/iiab/uuid
|
||||||
|
register: stored_uuid
|
||||||
|
|
||||||
|
- name: get the value into a variable
|
||||||
|
set_fact:
|
||||||
|
uuid={{ stored_uuid.stdout_lines[0] }}
|
||||||
|
|
||||||
# for rpi, without rtc, we need time as soon as possible
|
# for rpi, without rtc, we need time as soon as possible
|
||||||
- name: Install chrony package
|
- name: Install chrony package
|
||||||
package: name={{ item }}
|
package: name={{ item }}
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
# It can sourced in a shell script or read into an application
|
# It can sourced in a shell script or read into an application
|
||||||
XSCE_BASE_PATH={{ iiab_base }}
|
XSCE_BASE_PATH={{ iiab_base }}
|
||||||
XSCE_DIR={{ iiab_dir }}
|
XSCE_DIR={{ iiab_dir }}
|
||||||
OS={{ ansible_distribution }}
|
OS={{ ansible_local.local_facts.os }}
|
||||||
|
OS_VER={{ ansible_local.local_facts.os_ver }}
|
||||||
WWWROOT={{ doc_root }}
|
WWWROOT={{ doc_root }}
|
||||||
|
|
|
@ -32,3 +32,4 @@
|
||||||
value: '{{ ansible_date_time["iso8601"] }}'
|
value: '{{ ansible_date_time["iso8601"] }}'
|
||||||
- option: 'install_xo'
|
- option: 'install_xo'
|
||||||
value: '{{ xo_model }}'
|
value: '{{ xo_model }}'
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,11 @@ then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /etc/ansible/facts.d/local_facts.fact ]; then
|
||||||
|
mkdir -p /etc/ansible/facts.d
|
||||||
|
fi
|
||||||
|
cp ./scripts/local_facts.fact /etc/ansible/facts.d/local_facts.fact
|
||||||
|
|
||||||
PLAYBOOK="iiab.yml"
|
PLAYBOOK="iiab.yml"
|
||||||
INVENTORY="ansible_hosts"
|
INVENTORY="ansible_hosts"
|
||||||
CWD=`pwd`
|
CWD=`pwd`
|
||||||
|
|
50
roles/1-prep/templates/local_facts.fact.j2 → scripts/local_facts.fact
Normal file → Executable file
50
roles/1-prep/templates/local_facts.fact.j2 → scripts/local_facts.fact
Normal file → Executable file
|
@ -1,16 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
OS=`grep ^ID= /etc/*release|cut -d= -f2`
|
OS=`grep ^ID= /etc/*elease|cut -d= -f2`
|
||||||
OS=${OS//\"/}
|
OS=${OS//\"/}
|
||||||
|
VERSION_ID=`grep VERSION_ID /etc/*elease | cut -d= -f2`
|
||||||
|
VERSION_ID=${VERSION_ID//\"/}
|
||||||
|
VERSION_ID=${VERSION_ID%%.*}
|
||||||
|
OS_VER=$OS-$VERSION_ID
|
||||||
|
|
||||||
# enable this install config to be tracked
|
case $OS_VER in
|
||||||
if [ ! -f /etc/iiab/uuid ]; then
|
"fedora-18" | \
|
||||||
uuidgen > /etc/iiab/uuid
|
"fedora-22" | \
|
||||||
fi
|
"debian-8" | \
|
||||||
UUID=`cat /etc/iiab/uuid`
|
"debian-9" | \
|
||||||
|
"ubuntu-16" | \
|
||||||
source /etc/iiab/iiab.env
|
"centos-7" | \
|
||||||
cd $XSCE_DIR
|
"raspbian-8") break
|
||||||
|
;;
|
||||||
|
*) OS_VER="OS_not_supported"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
# get current version
|
# get current version
|
||||||
BRANCH=`git rev-parse --abbrev-ref HEAD`
|
BRANCH=`git rev-parse --abbrev-ref HEAD`
|
||||||
COMMIT=`git rev-parse --verify HEAD`
|
COMMIT=`git rev-parse --verify HEAD`
|
||||||
|
@ -33,33 +40,14 @@ else
|
||||||
XO_VERSION="none"
|
XO_VERSION="none"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /etc/iiab/iiab.env ]
|
|
||||||
then
|
|
||||||
. /etc/iiab/iiab.env
|
|
||||||
if [ -z $BASE_VERSION ]
|
|
||||||
then
|
|
||||||
BASE_VERSION="0"
|
|
||||||
fi
|
|
||||||
BASE="$BASE_VERSION"
|
|
||||||
else
|
|
||||||
BASE="0"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f /.preload ]
|
|
||||||
then
|
|
||||||
PRELOAD="True"
|
|
||||||
else
|
|
||||||
PRELOAD="False"
|
|
||||||
fi
|
|
||||||
ANSIBLE_VERSION=$(ansible --version|head -n 1|cut -f 2 -d " ")
|
ANSIBLE_VERSION=$(ansible --version|head -n 1|cut -f 2 -d " ")
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
{"phplib_dir" : "$PHPLIB_DIR",
|
{"phplib_dir" : "$PHPLIB_DIR",
|
||||||
"iiab_branch" : "$BRANCH",
|
"iiab_branch" : "$BRANCH",
|
||||||
"iiab_commit" : "$COMMIT",
|
"iiab_commit" : "$COMMIT",
|
||||||
"iiab_uuid" : "$UUID",
|
|
||||||
"xo_model" : "$XO_VERSION",
|
"xo_model" : "$XO_VERSION",
|
||||||
"iiab_base_ver" : "$BASE",
|
|
||||||
"ansble_version" : "$ANSIBLE_VERSION",
|
"ansble_version" : "$ANSIBLE_VERSION",
|
||||||
"os" : "$OS",
|
"os" : "$OS",
|
||||||
"iiab_preload" : "$PRELOAD"}
|
"os_ver" : "$OS_VER}
|
||||||
|
|
||||||
EOF
|
EOF
|
Loading…
Add table
Add a link
Reference in a new issue