Skip to content

Commit

Permalink
synchro with bitbucket 2.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
frsauvage committed Mar 3, 2020
1 parent 3de0ec5 commit 56d8af9
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 12 deletions.
121 changes: 121 additions & 0 deletions add_ansible_playbooks_and_plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/bin/sh

echo "checking ansible prerequisite"
ansible_version=$(ansible --version|grep "ansible python module location")
if [ -z "$ansible_version" ]
then
echo -e "\033[31mansible is NOT installed\033[0m"
exit -1
fi

if [ -z $ANSIBLE_CONFIG ]
then
export ANSIBLE_CONFIG=/etc/ansible/ansible.cfg
fi
echo "your ansible configuration file is $ANSIBLE_CONFIG"

if [ -z $ANSIBLE_INVENTORY ]
then
export ANSIBLE_INVENTORY=/etc/ansible/hosts #default
fi
echo "your ansible inventory hosts file is $ANSIBLE_INVENTORY"

add_lines()
{
echo -e "\033[32m---------------------------------------------------------------------------------------\033[0m"
echo -e "\033[31mPlease change yourself the following configuration in your $ANSIBLE_CONFIG:\033[0m"
echo "# MANDATORY: for atos module plugin to work, uncomment line at the begining of the file:"
echo -e "\033[31mlibrary = /usr/share/ansible/plugins/modules\033[0m"
echo "# MANDATORY: for atos module utils to work, uncomment line at the begining of the file:"
echo -e "\033[31mmodule_utils = /usr/share/ansible/plugins/module_utils\033[0m"
echo "# OPTION for a better Atos sensors / log / yaml rendering"
echo -e "stdout_callback = \033[32mmismunixy\033[0m"
echo "# OPTION if you wish a more human-readable rendering"
echo "See https://docs.ansible.com/ansible/2.5/plugins/callback.html#managing-adhoc"
echo -e "bin_ansible_callbacks = \033[32mTrue\033[0m"
echo "# to enable Atos python3 playbboks"
echo -e "ansible_python_interpreter = \033[32m/usr/bin/python3\033[0m"
echo "# if target certificates are self-signed"
echo "host_key_checking = False"
echo -e "\033[32m----------------------------------------------------------------------------------------\033[0m"
}

while true; do
read -p "Do you wish to overwrite your $ANSIBLE_CONFIG file ? y yes / n no: " yn
case $yn in
[Yy]* ) cp ansible/inventory/ansible.cfg $ANSIBLE_CONFIG ; break;;
[Nn]* ) add_lines; break;;
* ) echo "Please answer yes or no.";;
esac
done

# add ANSIBLE_PASSWORDS=<your install dir>/ansible/vars/passwords.yml to hosts file
# add ANSIBLE_EXTERNAL_VARS=<your install dir>/ansible/vars/external_vars.yml to hosts file
pwd=$(pwd)
export ANSIBLE_PASSWORDS=$pwd/ansible/vars/passwords.yml
export ANSIBLE_EXTERNAL_VARS=$pwd/ansible/vars/external_vars.yml

if [ ! -f $pwd/ansible/vars/passwords.yml ]
then
echo -e "\033[32mansible/vars/passwords.yml was successfully created\033[0m"
touch $pwd/ansible/vars/passwords.yml
fi

# delete old ANSIBLE_PASSWORDS path
grep -q ANSIBLE_PASSWORDS= $ANSIBLE_INVENTORY && sed -i.bak '/ANSIBLE_PASSWORDS=.*/d' $ANSIBLE_INVENTORY
# add the new ANSIBLE_PASSWORDS path
sed -i "/all:vars/a ANSIBLE_PASSWORDS=$ANSIBLE_PASSWORDS" $ANSIBLE_INVENTORY
echo "The following line was added in your $ANSIBLE_INVENTORY:"
echo -e "\033[32mANSIBLE_PASSWORDS=$ANSIBLE_PASSWORDS\033[0m"
echo -e "your passwords.yml file is now $ANSIBLE_PASSWORDS"
echo -e "you should copy your passwords in $ANSIBLE_PASSWORDS"
echo -e "\033[32m----------------------------------------------------------------------------------------\033[0m"

# delete old ANSIBLE_EXTERNAL_VARS path
grep -q ANSIBLE_EXTERNAL_VARS= $ANSIBLE_INVENTORY && sed -i.bak '/ANSIBLE_EXTERNAL_VARS=.*/d' $ANSIBLE_INVENTORY
# add the new ANSIBLE_EXTERNAL_VARS path
sed -i "/all:vars/a ANSIBLE_EXTERNAL_VARS=$ANSIBLE_EXTERNAL_VARS" $ANSIBLE_INVENTORY
echo "The following line was added in your $ANSIBLE_INVENTORY :"
echo -e "\033[32mANSIBLE_EXTERNAL_VARS=$ANSIBLE_EXTERNAL_VARS\033[0m"
echo -e "your external_vars.yml file is now $ANSIBLE_EXTERNAL_VARS"
echo -e "you should edit your var preferences in $ANSIBLE_EXTERNAL_VARS"
echo -e "\033[32m----------------------------------------------------------------------------------------\033[0m"
# ansible plugin inventory is copied in default directory /usr/lib/python<major>.<minor>/site-packages/ansible/modules
# you can adapt it if you have another ansible plugin inventory directory

# ansible plugin module is copied in default shared directory /usr/share/ansible/plugins/modules/
# you can adapt it if you have another ansible plugin module directory


if [ ! -d "/usr/share/ansible/plugins/callback/ansible_stdout_compact_logger" ]
then
mkdir -p /usr/share/ansible/plugins/callback/ansible_stdout_compact_logger
fi

cp -r ansible/plugins/callback/ansible_stdout_compact_logger/mismunixy.py /usr/share/ansible/plugins/callback/ansible_stdout_compact_logger/mismunixy.py


if [ ! -d "/usr/share/ansible/plugins/modules" ]
then
mkdir -p /usr/share/ansible/plugins/modules
fi

if [ ! -d "/usr/share/ansible/plugins/module_utils" ]
then
mkdir -p /usr/share/ansible/plugins/module_utils
fi

cp ansible/plugins/modules/remote_management/openbmc/atos_openbmc.py /usr/share/ansible/plugins/modules/atos_openbmc.py
cp ansible/plugins/modules/remote_management/openbmc/atos_openbmc_utils.py /usr/share/ansible/plugins/module_utils/atos_openbmc_utils.py
cp ansible/plugins/modules/remote_management/openbmc/__init__.py /usr/share/ansible/plugins/modules/__init__.py

# previous install issue
if [ -d "/usr/share/ansible/plugins/callback/ansible_stdout_compact_logger/ansible_stdout_compact_logger" ]
then
rm -rf /usr/share/ansible/plugins/callback/ansible_stdout_compact_logger/ansible_stdout_compact_logger
fi

if [ -d "/usr/share/ansible/plugins/callback/ansible_stdout_compact_logger/callback" ]
then
rm -rf /usr/share/ansible/plugins/callback/ansible_stdout_compact_logger/callback
fi
7 changes: 7 additions & 0 deletions add_awx_playbooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

echo "adding playbooks ..."
docker exec -it awx_web projects/add_playbooks.py

echo -e "\033[32mif you get an error: check https://localhost/api/v2/ on the docker host and re-run this script\033[0m"

Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@
body_format: json
when: reboot == true

- name: pause {{ reboot_countdown }} minuts for BMC to reboot
- name: pause {{ reboot_countdown }} minutes for BMC to reboot
pause:
minuts: "{{ reboot_countdown }}"
minutes: "{{ reboot_countdown }}"
when: reboot == True and item.value.Activation is defined and item.value.Purpose is defined and item.value.Activation == "xyz.openbmc_project.Software.Activation.Activations.Ready" and item.value.Purpose == "xyz.openbmc_project.Software.Version.VersionPurpose.BMC"
with_dict: "{{ firmware_inventory }}"

Expand Down
4 changes: 2 additions & 2 deletions ansible/playbooks/openbmc/firmware/update_firmwares.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@
var: evaluate_firmware_update
when: evaluate_firmware_update is defined

- name: pause {{ reboot_countdown }} minuts for BMC to reboot
- name: pause {{ reboot_countdown }} minutes for BMC to reboot
pause:
minuts: "{{ reboot_countdown }}"
minutes: "{{ reboot_countdown }}"
when: reboot == True and item.value.Purpose is defined and item.value.RequestedActivation is defined and item.value.Purpose == "xyz.openbmc_project.Software.Version.VersionPurpose.BMC" and item.value.RequestedActivation == "xyz.openbmc_project.Software.Activation.RequestedActivations.Active"
with_dict: "{{ firmware_inventory }}"

Expand Down
9 changes: 5 additions & 4 deletions ansible/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Ansible playbooks can be used as is with following prerequisites:
* AWX 4.0+
* Ansible 2.8.5+
* Python 3.6.8+
* modules Python : ansible-vault and tzlocal (delivered in "prerequisites" directory)

Optionaly, 2 ready-to-go AWX-Ansible images are available on Dockerhub
* Dockerhub AWX images
Expand Down Expand Up @@ -116,7 +117,7 @@ git clone https://github.com/atosorigin/bullsequana-edge-system-management.git
Bull Sequana Edge Ansible Extensions has 3 AWX installers and an option to try it
Just choose your favorite installation for your environment
`on existing AWX:` nothing to install: go to the next section to add playbooks and plugins
`full install: <install_dir>/install.sh` it will build full docker containers and install all containers with your local Dockerfiles that you can adapt as needed => use **stop.sh** and **start.sh** after
`full install: <install_dir>/install.sh` Full install : it will load all docker containers and optionnaly install Ansible playbooks and plugins => use **stop.sh** and **start.sh** after
`partial install AWX: <install_dir>/install_awx.sh` it will build docker containers and install Ansible/AWX docker containers with your local Dockerfiles that you can adapt as needed => use **stop_awx.sh** and **start_awx.sh** after
`try it: <install_dir>/install_awx_from_dockerhub.sh` mainly dedicated to try bullsequana edge system management tool, it will install dockerhub atosorigin images, you cannot adapt the local Dockerfiles => use **stop_awx.sh*** and **start_awx.sh** after

Expand All @@ -134,7 +135,7 @@ run a browser with: ` https://<your_server>`
### add your playbooks
If you did not already add your playbooks, just run:

`<install_dir>/add_playbooks.sh`
`<install_dir>/add_awx_playbooks.sh`

![alt text](https://raw.githubusercontent.com/atosorigin/bullsequana-edge-system-management/master/ansible/doc/awx_playbooks.png)

Expand All @@ -147,7 +148,7 @@ You should have now:
- 1 Credential : Bull Sequana Edge Vault
- Bull playbooks

![#f03c15](https://placehold.it/15/f03c15/000000?text=+) Warning: on existing installation, tower-cli should be installed to run add_playbooks.sh
![#f03c15](https://placehold.it/15/f03c15/000000?text=+) Warning: on existing installation, tower-cli should be installed to run add_awx_playbooks.sh

### complete your inventory first
1. go to Inventory
Expand Down Expand Up @@ -249,7 +250,7 @@ Following playbooks need these variables:
### use your credential

#### - change your vault password
The *add_playbooks.sh* script already creates a vault for you and associates every templates to this vault.
The *add_awx_playbooks.sh* script already creates a vault for you and associates every templates to this vault.

![alt text](https://raw.githubusercontent.com/atosorigin/bullsequana-edge-system-management/master/ansible/doc/create_vault_playbooks.png)

Expand Down
12 changes: 12 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/bin/sh

echo -e "\033[32mThis will install AWX and Zabbix\033[0m"

while true; do
read -p "Do you wish to install Ansible playbooks and plugins too: [yn yes no] " yn
case $yn in
[Yy]* ) ./install_ansible_playbooks_and_plugins.sh; break;;
[Nn]* ) break;;
* ) echo "Please answer y yes or n no.";;
esac
done

./install_awx.sh
./install_zabbix.sh


2 changes: 1 addition & 1 deletion install_awx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ docker-compose -f docker_compose_awx.yml up -d
echo "----------------------------------------------------------------------------------------------------"
echo "now wait 10 minutes for the migration to complete...."
echo "check the login page at https://localhost"
echo "and run ./add_playbooks.sh"
echo "and run ./add_awx_playbooks.sh"
echo "AWX is available on https://localhost"
echo "pgadmin is available on http://localhost:7070"
echo "for more info, refer to github site https://github.com/atosorigin/bullsequana-edge-system-management"
Expand Down
5 changes: 3 additions & 2 deletions install_awx_from_atos_dockerhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ echo "starting BullSequana Edge Ansible AWX containers ...."
docker-compose -f docker_compose_awx_from_atos_dockerhub.yml up -d

echo "----------------------------------------------------------------------------------------------------"
echo "now wait 10 minutes for the migration to complete...."
echo "check the login page at https://localhost"
echo "and run ./add_awx_playbooks.sh"
echo "AWX is available on https://localhost"
echo "pgadmin is available on http://localhost:7070"
echo "for more info, refer to github site https://github.com/atosorigin/bullsequana-edge-system-management"
echo "----------------------------------------------------------------------------------------------------"



Binary file added prerequisites/tzlocal-2.0.0.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion zabbix/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ For more details, read the [How to change your Proxy](#howto_proxy) section
Bull Sequana Edge Zabbix Extensions has 3 Zabbix installers and an option to try it
Just choose your favorite installation for your environment
`on existing zabbix: import Atos templates`: you can import Atos templates in your Zabbix environment if you have an existing Zabbix installation
`full: <install_dir>/install.sh` it will build and install Ansible and Zabbix Bull Sequana Edge Extensions docker containers at once from your local Dockerfiles => use **stop.sh** and **start.sh** after
`full install: <install_dir>/install.sh` Full install - All in Once - it will load all docker containers and optionnaly install Ansible playbooks and plugins => use **stop.sh** and **start.sh** after
`partial: <install_dir>/install_zabbix.sh` it will build and install only Zabbix docker containers from your local Dockerfiles that you can adapt as needed => use **stop_zabbix.sh** and **start_zabbix.sh** after
`try it: <install_dir>/install_zabbix_from_dockerhub.sh` mainly dedicated to try bullsequana edge system management tool, it will install dockerhub atosorigin images, you cannot adapt the local Dockerfiles => use **stop_zabbix.sh*** and **start_zabbix.sh** after
For more information about dockerhub installation Visit https://hub.docker.com/repository/docker/atosorigin/bull-sequana-edge-zabbix-server
Expand Down

0 comments on commit 56d8af9

Please sign in to comment.