Skip to content

Commit

Permalink
Merge branch 'devel' into offline_repo
Browse files Browse the repository at this point in the history
  • Loading branch information
j0hnL committed Sep 7, 2021
2 parents 2bfa982 + 8c27c6b commit c69ab36
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 129 deletions.
18 changes: 8 additions & 10 deletions control_plane/roles/control_plane_device/files/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
# Dockerfile for creating the management network container

FROM centos:7
FROM centos:8

# RPM REPOs
RUN yum install -y \
RUN dnf install -y \
epel-release \
&& yum clean all \
&& rm -rf /var/cache/yum
&& dnf clean all \
&& rm -rf /var/cache/dnf

RUN yum update -y \
&& yum clean all \
&& rm -rf /var/cache/yum
RUN dnf install -y dhcp-server
RUN dnf install -y python3-netaddr

RUN yum install -y \
ansible \
cronie \
tftp\
tftp-server\
dhcp \
xinetd \
net-tools \
&& yum clean all \
Expand All @@ -28,10 +26,10 @@ RUN mkdir /root/omnia
#Copy Configuration files
COPY dhcpd.conf /etc/dhcp/dhcpd.conf
COPY tftp /etc/xinetd.d/tftp
COPY inventory_creation.yml /root/
COPY mngmnt_container_configure.yml /root/

RUN systemctl enable tftp
RUN systemctl enable dhcpd

CMD ["sbin/init"]

CMD ["sbin/init"]
48 changes: 0 additions & 48 deletions control_plane/roles/control_plane_device/files/dhcpd.conf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---

- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Read dhcp file
set_fact:
var: "{{ lookup('file', '/var/lib/dhcpd/dhcpd.leases').split()| unique | select| list }}"

- name: Filter the ip
set_fact:
vars_new: "{{ var| ipv4('address')| to_nice_yaml}}"

- name: Create the static ip
shell: awk -F',' 'NR >1{print $2}' /root/omnia/control_plane/roles/control_plane_device/files/new_mngmnt_mapping_file.csv > static_hosts.yml
changed_when: false
failed_when: false

- name: Create the dynamic inventory
shell: |
echo "{{ vars_new }}" > temp.txt
egrep -o '[1-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' temp.txt >>dynamic_hosts.yml
changed_when: false
failed_when: false

- name: Final inventory
shell: cat dynamic_hosts.yml static_hosts.yml| sort -ur >> omnia/control_plane/roles/collect_device_info/files/mgmt_provisioned_hosts.yml
changed_when: false

- name: Temp result
shell: cat /root/omnia/control_plane/roles/collect_device_info/files/mgmt_provisioned_hosts.yml |sort|uniq
register: inventory

- name: Final Inventory
local_action: copy content="{{ inventory.stdout }}" dest=omnia/control_plane/roles/collect_device_info/files/mgmt_provisioned_hosts.yml

- name: New line at end of file
shell: echo "">> omnia/control_plane/roles/collect_device_info/files/mgmt_provisioned_hosts.yml
changed_when: false
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ spec:
- name: omnia-storage
mountPath: /root/omnia
securityContext:
privileged: true
privileged: true
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,15 @@
- name: Start dhcpd services
service:
name: dhcpd
state: started
state: started

- name: Fetch ansible-playbook location
command: whereis ansible-playbook
changed_when: false
register: ansible_playbook_location

- name: Add inventory cron job
cron:
name: Create inventory
minute: "*/5"
job: "{{ ansible_playbook_location.stdout.split(' ')[1] }} /root/inventory_creation.yml"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# ******************************************************************
# Cobbler managed dhcpd.conf file
#
Expand Down Expand Up @@ -45,4 +44,4 @@ next-server next_server;

}

#end for
#end for
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIiND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
Expand All @@ -17,22 +17,21 @@
set_fact:
mngmnt_network_container_status: false
mngmnt_network_container_image_status: false
mngmnt_network_container_config_status: false
backup_map_status: false
new_node_status: false
backup_mngmnt_map_status: false
new_mngmnt_node_status: false
tags: install

- name: Check if any backup file exists
block:
- name: Check status of backup file
stat:
path: "{{ role_path }}/files/backup_mapping_file.csv"
register: backup_map
path: "{{ role_path }}/files/backup_mngmnt_mapping_file.csv"
register: backup_mngmnt_map

- name: Set status for backup file
set_fact:
backup_map_status: true
when: backup_map.stat.exists == true
backup_mngmnt_map_status: true
when: backup_mngmnt_map.stat.exists
rescue:
- name: Message
debug:
Expand All @@ -42,14 +41,14 @@
- name: Inspect the mngmnt_network_container image
command: "buildah images {{ mngmnt_network_image_name }}"
register: mngmnt_network_container_image_result
ignore_errors: true
failed_when: false
changed_when: false
tags: install

- name: Check mngmnt_network_container status on the machine
command: kubectl get pods -n network-config
register: mngmnt_network_container_result
ignore_errors: true
failed_when: false
changed_when: false
tags: install

Expand All @@ -64,9 +63,3 @@
mngmnt_network_container_status: true
when: "'mngmnt-network-container' in mngmnt_network_container_result.stdout"
tags: install

- name: Update mngmnt_network_container status
set_fact:
mngmnt_network_container_config_status: true
when:
- mngmnt_network_container_status == true
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
command: kubectl get pods -n network-config
changed_when: false
register: mngmnt_network_pod_status
ignore_errors: true

- name: Deploy mngmnt_network pod
command: "kubectl apply -f {{ role_path }}/files/k8s_mngmnt_network.yml"
changed_when: true
tags: install
when: mngmnt_network_container_status == true and mngmnt_network_container_config_status == false
failed_when: false

- name: Wait for mngmnt_network pod to come to ready state
command: kubectl wait --for=condition=ready -n network-config pod -l app=mngmnt-network
Expand All @@ -38,15 +32,15 @@

- name: Configuring mngmnt_network container
command: 'kubectl exec --stdin --tty -n network-config {{ mngmnt_network_pod_name.stdout }} \
-- ansible-playbook /root/omnia/control_plane/roles/control_plane_device/files/mngmnt_container_configure.yml'
-- ansible-playbook /root/mngmnt_container_configure.yml'
changed_when: false
tags: install
when: mngmnt_network_container_config_status == false
when: not mngmnt_network_container_status

- name: Schedule task
cron:
name: "start mngmnt_network_container on reboot"
special_time: reboot
job: "ansible-playbook {{ role_path }}/files/start_mngmnt_container.yml"
tags: install
#when: mngmnt_network_container_config_status == false
- name: Remove the files
file:
path: "{{ item }}"
state: absent
with_items:
- "{{ role_path }}/files/dhcpd.conf"
- "{{ role_path }}/files/temp_mgmt_mapping_file.csv.bak"
20 changes: 9 additions & 11 deletions control_plane/roles/control_plane_device/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,15 @@
when: not mngmnt_network_container_status

- name: Include variable file base_vars.yml
include_vars: "{{ mngmnt_base_file }}"

#- name: Fetch base inputs
# include_tasks: ../../control_plane_common/tasks/fetch_base_inputs.yml
# when: not mngmnt_network_container_status
include_vars: "{{ base_mngmnt_file }}"

- name: Dhcp Configuration
import_tasks: dhcp_configure.yml
when: (not mngmnt_network_container_image_status) or ( backup_map_status == true)
when: (not mngmnt_network_container_image_status) or ( backup_mngmnt_map_status)

#- name: Mapping file validation
# import_tasks: mapping_file.yml
# when: (not mngmnt_network_container_image_status) and (mapping_file == true) or ( backup_map_status == true)
- name: Mapping file validation
import_tasks: mapping_file.yml
when: (not mngmnt_network_container_image_status) and (mngmnt_mapping_file_path) or ( backup_mngmnt_map_status)

- name: mngmnt_network_container image creation
import_tasks: mngmnt_network_container_image.yml
Expand All @@ -54,11 +50,13 @@

- name: mngmnt_network_container container status message
block:
- debug:
- name: management network container running
debug:
msg: "{{ message_skipped }}"
verbosity: 2
when: mngmnt_network_container_status
- debug:
- name: management network container not running
debug:
msg: "{{ message_installed }}"
verbosity: 2
when: not mngmnt_network_container_status
Expand Down
Loading

0 comments on commit c69ab36

Please sign in to comment.