Skip to content

Commit

Permalink
synchro with bitbucket 2.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
frsauvage committed Jan 22, 2020
1 parent 17cb5bf commit d59952e
Show file tree
Hide file tree
Showing 31 changed files with 160 additions and 195 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# TODO uncomment to get tar files
*.tar
!prerequisites/*.tar
*.gz
!prerequisites/*.gz
*.bak
bull*.zip

Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/Dockerfile-awx_task.tag
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ansible/awx_task:9.0.1

USER root

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.4
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.5

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.tag
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ansible/awx_web:9.0.1

USER root

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.4
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.5

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

USER root

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.4
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.5

ENV PYTHONWARNINGS="ignore:Unverified HTTPS request"

Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/Dockerfile-zabbix-web.tag
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#set base image
FROM zabbix/zabbix-web-nginx-pgsql:centos-4.4.1

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.4
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.5

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/Dockerfile-zabbix.tag
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM zabbix/zabbix-server-pgsql:centos-4.4.1

USER root

ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.4
ENV MISM_BULLSEQUANA_EDGE_VERSION=2.0.5

ENV PYTHONWARNINGS="ignore:Unverified HTTPS request"

Expand Down
2 changes: 1 addition & 1 deletion Dockerfiles/ansible.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RABBITMQ_DEFAULT_USER=mism
RABBITMQ_DEFAULT_PASS=mismpass
AWX_ADMIN_USER=mism
AWX_ADMIN_PASSWORD=mismpass
ANSIBLE_INVENTORY=/var/lib/awx/inventory
ANSIBLE_INVENTORY=/var/lib/awx/inventory/hosts
TOWER_HOST=https://localhost:8052
TOWER_USERNAME=mism
TOWER_PASSWORD=mismpass
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.0.4
version: 2.0.5
</div>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions ansible/inventory/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
#inventory = /etc/ansible/hosts
#library = /usr/share/my_modules/
#module_utils = /usr/share/my_module_utils/
#library = /usr/share/ansible/plugins/modules/
module_utils = /usr/share/ansible/plugins/modules/
library = /usr/share/ansible/plugins/modules/
#module_utils = /usr/share/ansible/plugins/modules/
module_utils = /usr/share/ansible/plugins/module_utils/
#remote_tmp = ~/.ansible/tmp
#local_tmp = ~/.ansible/tmp
#plugin_filters_cfg = /etc/ansible/plugin_filters.yml
Expand Down Expand Up @@ -494,5 +495,5 @@ bin_ansible_callbacks = True

force_valid_group_names = False
deprecation_warnings = False
ansible_python_interpreter=/usr/bin/python3
#ansible_python_interpreter=/usr/bin/python3

5 changes: 5 additions & 0 deletions ansible/inventory/hosts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[all:vars]
host="{{inventory_hostname}}"
# usefull only for docker CLI Ansible
ANSIBLE_PASSWORDS = "/etc/ansible/vars/passwords.yml"
ANSIBLE_EXTERNAL_VARS = "/etc/ansible/vars/external_vars.yml"
# uncomment if your python interpreter is python3
#ansible_python_interpreter=/usr/bin/python3

#[openbmc]
# <here an IP address> baseuri="{{host}}" username=<here bmc username> password=<here bmc password>
Expand Down
122 changes: 71 additions & 51 deletions ansible/playbooks/add_playbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def __init__(self, **entries):
c = yaml.load(open(playbooks).read())
tower = Config(**c)

bool_force_create=False

org_res = tower_cli.get_resource('organization')
inv_res = tower_cli.get_resource('inventory')
host_res = tower_cli.get_resource('host')
Expand All @@ -47,68 +49,87 @@ def __init__(self, **entries):
org_id = org['id']

if tower.credentials:
# create one credential
print("Creating Bull Sequana Edge Vault\n")
for i in tower.credentials:
#print(i)
vault = cred_type.get(name=i['credential_type'])
i['credential_type'] = vault['id']
i['organization'] = org_id
cred = cred_res.create(**i)

try:
vault = cred_type.get(name=i['credential_type'])
i['credential_type'] = vault['id']
i['organization'] = org_id
cred = cred_res.get(name=i['name'])
print("Bull Sequana Edge Vault already exists\n")
except:
cred = cred_res.create(**i)
print("Creating Bull Sequana Edge Vault\n")
bool_force_create=True

if tower.inventories:
# create inventories
print("Creating Inventories\n")
for i in tower.inventories:
#print(i)
# create inventories
for i in tower.inventories:
i['organization'] = org_id
inv = inv_res.create(**i)
# create dynamic groups, static ones can be imported better with awx-manage
if 'groups' in i:
for g in i['groups']:
#print(g)
g['inventory'] = inv['id']
# set the credential if this group has one
group = group_res.create(**g)
# sync the group if it has a credential
if 'group' in group:
id = group['group']
elif 'id' in group :
id = group['id']
if 'credential' in g:
group_res.sync(id)
if 'hosts' in g:
for h in g['hosts']:
h['inventory'] = inv['id']
#print(h)
host = host_res.create(**h)
host_res.associate(host=host['id'], group=group['id'])

try:
inv = inv_res.get(name=i['name'])
print("Updating Inventory: {name} variables\n".format(name=i['name']))
inv_res.modify(name=i['name'], variables=i['variables'])
except:
print("Creating Inventory: {name}\n".format(name=i['name']))
inv = inv_res.create(**i)
bool_force_create=True
# create dynamic groups, static ones can be imported better with awx-manage
if 'groups' in i:
for g in i['groups']:
#print(g)
g['inventory'] = inv['id']
# set the credential if this group has one
group = group_res.create(**g)
# sync the group if it has a credential
if 'group' in group:
id = group['group']
elif 'id' in group :
id = group['id']
if 'credential' in g:
group_res.sync(id)
if 'hosts' in g:
for h in g['hosts']:
h['inventory'] = inv['id']
#print(h)
host = host_res.create(**h)
host_res.associate(host=host['id'], group=group['id'])

if tower.projects:
# create projects
print("Creating Project: Playbooks {version} for BullSequana Edge\n".format(version=os.environ.get('MISM_BULLSEQUANA_EDGE_VERSION')))
for p in tower.projects:
#print(p)
p['organization'] = org_id
p['description'] = "Playbooks {version} for BullSequana Edge".format(version=os.environ.get('MISM_BULLSEQUANA_EDGE_VERSION'))
project_res.create(**p)
p['description'] = "Playbooks {version} for BullSequana Edge".format(version=os.environ.get('MISM_BULLSEQUANA_EDGE_VERSION'))
try:
proj = project_res.get(name=p['name'])
print("Updating Project: {name} description\n".format(name=p['name']))
project_res.modify(name=p['name'], description=p['description'])
except:
print("Creating Project: Playbooks {version} for BullSequana Edge\n".format(version=os.environ.get('MISM_BULLSEQUANA_EDGE_VERSION')))
p['organization'] = org_id
project_res.create(**p)
bool_force_create=True

if tower.job_templates:
print("Waiting 30 seconds for projects to index.")
print("Press any key to skip if you know what you're doing.")
timeout = 30
rlist, wlist, xlist = select([sys.stdin], [], [], timeout)
# create job templates
print("Creating Job Templates...\n")
for j in tower.job_templates:
print(j)
inv = inv_res.get(name=j['inventory'])
j['inventory'] = inv['id']
project = project_res.get(name=j['project'])
j['project'] = project['id']
j['organization'] = org_id
j['credential'] = cred['id']
job_template_res.create(**j)
try:
inv = inv_res.get(name=j['inventory'])
j['inventory'] = inv['id']
project = project_res.get(name=j['project'])
j['project'] = project['id']
j['organization'] = org_id
j['credential'] = cred['id']
if bool_force_create :
print(" Creating Job Template {name}\n".format(name=j['name']))
job_template_res.create(**j)
continue
else:
job_temp = job_template_res.get(name=j['name'])
print(" Job Template {name} already exists\n".format(name=j['name']))
except:
print(" Creating Job Template {name}\n".format(name=j['name']))
job_template_res.create(**j)

print("-----------------------------------------------------------------------------------------")
print("What to do first ?")
Expand All @@ -119,4 +140,3 @@ def __init__(self, **entries):
project_res.delete(name="Demo Project")
cred_res.delete(name="Demo Credential")
job_template_res.delete(name="Demo Job Template")

7 changes: 0 additions & 7 deletions ansible/playbooks/openbmc/utils/utils_create_token.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
fail_msg: "The variable ANSIBLE_PASSWORDS is NOT defined in inventory (AWX or Ansible default is /etc/ansible/hosts) file. See readme.md for more details."
success_msg: "The variable ANSIBLE_PASSWORDS is defined"

- name: assert ANSIBLE_EXTERNAL_VARS path
assert:
that:
- ANSIBLE_EXTERNAL_VARS is defined
fail_msg: "The variable ANSIBLE_EXTERNAL_VARS is NOT defined in inventory (AWX) or /etc/ansible/hosts file (Ansible). See readme.md for more details."
success_msg: "The variable ANSIBLE_EXTERNAL_VARS is defined"

- name: Secure passwords file
debug:
msg: "Path to passwords file is {{ ANSIBLE_PASSWORDS }}"
Expand Down
6 changes: 4 additions & 2 deletions docker_compose_awx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ services:
volumes:
- ./ansible/playbooks:/var/lib/awx/projects:rw
- ./ansible/inventory:/var/lib/awx/inventory:rw
- ./ansible/inventory:/etc/ansible:rw
# - ./ansible/inventory:/etc/ansible:rw
- ./ansible/vars:/etc/ansible/vars:rw
# - ./ansible/vars:/var/lib/awx/inventory/vars:rw
# - ./ansible/plugins/inventory/redfish_plugin_ansible_inventory.yml:/usr/lib/python3.6/site-packages/ansible/plugins/inventory/redfish_plugin_ansible_inventory.yml
# - ./ansible/plugins/inventory/redfish_plugin_ansible_inventory.yml:/usr/share/ansible/plugins/inventory/redfish_plugin_ansible_inventory.yml
# - ./ansible/plugins/inventory/redfish_plugin_ansible_inventory.py:/usr/lib/python3.6/site-packages/ansible/plugins/inventory/redfish_plugin_ansible_inventory.py
Expand Down Expand Up @@ -54,8 +55,9 @@ services:
volumes:
- ./ansible/playbooks:/var/lib/awx/projects:rw
- ./ansible/inventory:/var/lib/awx/inventory:rw
- ./ansible/inventory:/etc/ansible:rw
# - ./ansible/inventory:/etc/ansible:rw
- ./ansible/vars:/etc/ansible/vars:rw
# - ./ansible/vars:/var/lib/awx/inventory/vars:rw
# - ./ansible/plugins/inventory/redfish_plugin_ansible_inventory.yml:/usr/share/ansible/plugins/inventory/redfish_plugin_ansible_inventory.yml
# - ./ansible/plugins/inventory/redfish_plugin_ansible_inventory.py:/usr/lib/python3.6/site-packages/ansible/plugins/inventory/redfish_plugin_ansible_inventory.py
# - ./ansible/plugins/inventory/:/usr/share/ansible/plugins/inventory
Expand Down
2 changes: 1 addition & 1 deletion generate_encrypted_password_for_AWX.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ else
# extract variable name to help user
name_variable=$(echo "$result_ansible_vault_password" | awk -F: '{print$1}')
echo "you can now use your variable in your Ansible inventory"
echo -e "go to Inventory, select your host(s) and add \033[32mpassword: '{{ $name_variable }}' \033[0m in extra vars section"
echo -e "go to Inventory, select your host(s) and modify \033[32mpassword: '{{ $name_variable }}' \033[0m in VARIABLES section"
fi

if test -f "/tmp/fileEncrypt$$"
Expand Down
2 changes: 1 addition & 1 deletion generate_encrypted_password_for_Ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ else
# extract variable name to help user
name_variable=$(echo "$result_ansible_vault_password" | awk -F: '{print$1}')
echo "you can now use your variable in your Ansible inventory"
echo -e "edit the your /etc/ansible/hosts file and add \033[32mpassword: '{{ $name_variable }}' \033[0m"
echo -e "edit the your hosts and modify \033[32mpassword=\"{{ $name_variable }}\" \033[0m"
fi

if test -f "/tmp/fileEncrypt$$"
Expand Down
2 changes: 1 addition & 1 deletion install_playbooks_and_plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ add_lines()
{
echo -e "\033[32m---------------------------------------------------------------------------------------\033[0m"
echo -e "\033[32mPlease change yourself the following configuration in your $ANSIBLE_CONFIG:\033[0m"
echo "# MADATORY: for atos plugin to work, uncomment line at the begining of thefile:"
echo "# MANDATORY: for atos plugin to work, uncomment line at the begining of thefile:"
echo -e "\033[32mmodule_utils = /usr/share/ansible/plugins/modules\033[0m"
echo "# OPTION for a better Atos sensors / log / yaml rendering"
echo -e "stdout_callback = \033[31mmismunixy\033[0m"
Expand Down
Loading

0 comments on commit d59952e

Please sign in to comment.