Skip to content

Commit

Permalink
deliverable 2.1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
frsauvage committed Jan 12, 2022
1 parent a87b04a commit 1339817
Show file tree
Hide file tree
Showing 31 changed files with 473 additions and 177 deletions.
2 changes: 1 addition & 1 deletion Dockerfiles/Dockerfile-awx_task
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM $REGISTRY/$BASE_IMAGE_AWX_TASK:$TAG_AWX

USER root

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.9
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.10

COPY ansible.credentials.py /etc/tower/conf.d/credentials.py
COPY ansible.env /etc/tower/conf.d/environment.sh
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/Dockerfile-awx_web
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM $REGISTRY/$BASE_IMAGE_AWX_WEB:$TAG_AWX

USER root

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.9
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.10

# security
COPY ansible.credentials.py /etc/tower/conf.d/credentials.py
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/Dockerfile-zabbix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM $REGISTRY/$BASE_IMAGE_ZABBIX:$TAG_ZABBIX

USER root

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.9
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.10

ENV PYTHONWARNINGS="ignore:Unverified HTTPS request"

Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/Dockerfile-zabbix-agent
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM $REGISTRY/$BASE_IMAGE_ZABBIX_AGENT:$TAG_ZABBIX

USER root

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.9
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.10

ENV PYTHONWARNINGS="ignore:Unverified HTTPS request"

Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/Dockerfile-zabbix-web
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG MISM_BULLSEQUANA_EDGE_VERSION

FROM $REGISTRY/$BASE_IMAGE_ZABBIX_WEB:$TAG_ZABBIX

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.9
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.1.10

COPY items.inc.php /usr/share/zabbix/include/
COPY logo-header.svg /usr/share/zabbix/assets/img/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/loginModal.partial.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
</div>
</div>
<div class="LoginModal-footer">
version: 2.1.9
version: 2.1.10
</div>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions add_awx_playbooks.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

export MISM_BULLSEQUANA_EDGE_PLAYBOOKS_VERSION=2.1.9
export MISM_BULLSEQUANA_EDGE_PLAYBOOKS_VERSION=2.1.10


###################################################################################################################
# passwords.yml
Expand All @@ -20,4 +21,4 @@ fi
echo "adding playbooks ..."
docker exec -e MISM_BULLSEQUANA_EDGE_PLAYBOOKS_VERSION=$MISM_BULLSEQUANA_EDGE_PLAYBOOKS_VERSION -it awx_web projects/add_playbooks.py

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

79 changes: 66 additions & 13 deletions ansible/playbooks/add_playbooks.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
#!/usr/bin/env python3
# # -*- coding: utf-8 -*-
#
# Atos BullSequana Edge Ansible Modules
# Version 2.0
# Copyright (C) 2019 Atos or its subsidiaries. All Rights Reserved.
# -*- coding: utf-8 -*-

# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
# Inspired from https://github.com/jsmartin/tower_populator
"""
This script add ansible playbooks to awx
This script is called fomr add_awx_playbooks.sh file
Inspired from https://github.com/jsmartin/tower_populator
Copyright (C) 2022 Atos
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
All users shall be bound by the terms and
conditions of the GNU General Public License v3.0
which are stated extensively at the following address :
https://www.gnu.org/licenses/gpl-3.0.en.html
"""

__author__ = "Francine Sauvage"
__contact__ = "support@atos.net"
__date__ = "2022/01/12"
__deprecated__ = False
__email__ = "francine.sauvage@atos.net"
__license__ = "GPLv3"
__status__ = "Production"
__version__ = "2.1.10"
__copyright__ = "Copyright 2022, Atos"
__maintainer__ = "Francine Sauvage"
__credits__ = ["Francine Sauvage"]

import yaml
import sys
Expand Down Expand Up @@ -84,26 +112,50 @@ def __init__(self, **entries):
existing_variables = {}
for match in matches:
existing_variables[match.group("cle")] = match.group("valeur")
#print(i['variables'].items())

for cle, valeur in i['variables'].items():
#print("{} {}".format(cle, valeur) )
if cle == 'ntp_server_sync':
existing_variables[cle] = 'NTP'
print("Key found => {} = {}".format(cle, 'NTP'))
continue
if not cle in existing_variables:
print("Key not found => Creating key={} with value={} in your ANSIBLE VARIABLES".format(cle, valeur))
if type(valeur)=="str" and valeur.isdigit():
if isinstance(valeur, "str") and valeur.isdigit():
print(type(valeur))
valeur = int(valeur)
existing_variables[cle]=valeur
else: # do NOT change existing variables
valeur_existing = existing_variables[cle]
if type(valeur_existing)=="str" and valeur_existing.isdigit():
if valeur_existing.isdigit():
valeur_existing = int(valeur_existing)
print("Key found => {} = {}".format(cle, valeur_existing))
print("Key found as integer => {} = {}".format(cle, valeur_existing))
elif isinstance(valeur_existing, bool) and valeur_existing :
print("Key found as True => {} = {}".format(cle, valeur_existing))
valeur_existing = True
elif isinstance(valeur_existing, bool) and not valeur_existing:
print("Key found as False => {} = {}".format(cle, valeur_existing))
valeur_existing = False
elif valeur_existing.lower() == 'true':
valeur_existing = True
print("Key found as bool=true => {} = {}".format(cle, valeur_existing))
elif valeur_existing.lower() == 'false':
valeur_existing = False
print("Key found as bool=false => {} = {}".format(cle, valeur_existing))
else :
print("Key found as string => {} = {}".format(cle, valeur_existing))
existing_variables[cle] = valeur_existing

result = yaml.dump(existing_variables)
# result = yaml.dump(existing_variables)
result = yaml.safe_dump(existing_variables, default_flow_style=False)
# print(result)
inv_res.modify(name=i['name'], variables=result)
print("Updated Inventory: {name} variables\n".format(name=i['name']))
except:
print("Exception !! Recreating Inventory: {name}\n".format(name=i['name']))
i['variables'] = yaml.dump(i['variables'])
i['variables'] = yaml.safe_dump(i['variables'], default_flow_style=False)
print(i['variables'])
inv = inv_res.create(**i)
bool_force_create=True
# create dynamic groups, static ones can be imported better with awx-manage
Expand All @@ -127,6 +179,7 @@ def __init__(self, **entries):
host = host_res.create(**h)
host_res.associate(host=host['id'], group=group['id'])


if tower.projects:
for p in tower.projects:
p['description'] = "Playbooks {version} for BullSequana Edge".format(version=os.environ.get('MISM_BULLSEQUANA_EDGE_PLAYBOOKS_VERSION'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@
X-Auth-Token: "{{ x_token }}"
body_format: json
body:
data: "{{ ntp_server_sync }}"
data: "xyz.openbmc_project.Time.Synchronization.Method.{{ntp_server_sync}}"
register: result_ntp_server_sync
25 changes: 25 additions & 0 deletions ansible/playbooks/openbmc/power/disable_ssh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- hosts: all
connection: local
name: Disable Ssh
gather_facts: False
vars_files:
- "{{ ANSIBLE_EXTERNAL_VARS }}"
- "{{ ANSIBLE_PASSWORDS }}"

tasks:

- include_tasks: ../utils/utils_create_token.yml

- name: diable SSH
uri:
url: https://{{ baseuri }}/xyz/openbmc_project/control/service/ssh/attr/Enabled
method: PUT
validate_certs: no
headers:
X-Auth-Token: "{{ x_token }}"
body_format: json
body:
data: false
register: result_disable_ssh

25 changes: 25 additions & 0 deletions ansible/playbooks/openbmc/power/enable_ssh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- hosts: all
connection: local
name: Enable Ssh
gather_facts: False
vars_files:
- "{{ ANSIBLE_EXTERNAL_VARS }}"
- "{{ ANSIBLE_PASSWORDS }}"

tasks:

- include_tasks: ../utils/utils_create_token.yml

- name: enable SSH
uri:
url: https://{{ baseuri }}/xyz/openbmc_project/control/service/ssh/attr/Enabled
method: PUT
validate_certs: no
headers:
X-Auth-Token: "{{ x_token }}"
body_format: json
body:
data: true
register: result_enable_ssh

18 changes: 16 additions & 2 deletions ansible/playbooks/playbooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inventories:
forceoff: true
reboot: true
ntp_server_ip: 127.0.0.1
ntp_server_sync: 604800
ntp_server_sync: NTP
rsyslog_server_ip: 0.0.0.0
rsyslog_server_port: 514
reboot_countdown: 2
Expand Down Expand Up @@ -238,7 +238,7 @@ job_templates:
playbook: inventory/set_ntp_server_ip_and_sync.yml
job-type: run
verbosity: 0
extra_vars: ["ntp_server_ip: 127.0.0.1", "ntp_server_sync: 604800"]
extra_vars: ["ntp_server_ip: 127.0.0.1", "ntp_server_sync: NTP"]
ask_variables_on_launch: 1
- name: System
description: Get System
Expand Down Expand Up @@ -375,3 +375,17 @@ job_templates:
verbosity: 0
extra_vars: ["power_cap: 500"]
ask_variables_on_launch: 1
- name: Enable ssh
description: Set SSH to Enabled
inventory: BullSequana Edge Inventory
project: BullSequana Edge Playbooks
playbook: power/enable_ssh.yml
job-type: run
verbosity: 0
- name: Disable ssh
description: Set SSH to Disabled
inventory: BullSequana Edge Inventory
project: BullSequana Edge Playbooks
playbook: power/disable_ssh.yml
job-type: run
verbosity: 0
3 changes: 2 additions & 1 deletion ansible/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -964,4 +964,5 @@ Ansible Help is accessible as Ansible Documentation :
This project is licensed under GPL-3.0 License. Please see the [COPYING](../COPYING.md) for more information

## <a name="version"></a>Version
BullSequana Edge System Management Tool version 2.0.1
BullSequana Edge System Management Playbook version 2.1.10
MISM_BULLSEQUANA_EDGE_PLAYBOOKS_VERSION=2.1.10
6 changes: 3 additions & 3 deletions get_bullsequana_edge_awx_system_management_version.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

echo "MISM_BULLSEQUANA_EDGE_VERSION environment variable is :"
echo "BullSequana Edge System Management Light version "
docker exec -it awx_web env |grep MISM_BULLSEQUANA_EDGE_VERSION


tail -1 ansible/readme.md
echo
6 changes: 3 additions & 3 deletions get_bullsequana_edge_zabbix_system_management_version.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

echo "MISM_BULLSEQUANA_EDGE_VERSION environment variable is :"
echo "BullSequana Edge System Management Light version "
docker exec -it zabbix-server env |grep MISM_BULLSEQUANA_EDGE_VERSION


tail -1 zabbix/readme.md
echo
Loading

0 comments on commit 1339817

Please sign in to comment.