Skip to content

Commit

Permalink
remove duplicate code (#3494)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroon-Khel authored Mar 28, 2024
1 parent d3d05a7 commit b26a406
Showing 1 changed file with 3 additions and 221 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
#################################################
# Build basic test images for each distribution #
#################################################
##########################################
# Config changes for Dockerhost machines #
##########################################

- name: Enable ipv6 on Dockerhost
lineinfile:
Expand All @@ -13,224 +13,6 @@
notify:
- Restart docker service

- name: Send Dockerfiles to remote machine
copy:
src: Dockerfiles/
dest: /tmp/Dockerfiles/

- name: Collate all Dockerfile names
find:
paths: "/tmp/Dockerfiles/"
patterns: "Dockerfile.*"
register: dockerfiles

# Defaulting to x64 in Dockerfiles means no need to special case that one
# since API architecture = ansible_architecture everywhere else we use this
- name: Translate architecture name in dockerfiles
replace: dest={{ item.path }} regexp="arch=x64" replace="arch={{ ansible_architecture }}"
with_items: "{{ dockerfiles.files }}"
when: ansible_architecture != "x86_64"

- name: Set jenkins authorized_Key in dockerfiles
replace: dest={{ item.path }} regexp="Jenkins_User_SSHKey" replace="{{ Jenkins_User_SSHKey }}"
with_items: "{{ dockerfiles.files }}"

- name: Create docker images for each distribution for test
command: docker build --cpu-period=100000 --cpu-quota=800000 -t aqa_{{ item }} --memory=8G -f /tmp/Dockerfiles/Dockerfile.{{ item }} /tmp/Dockerfiles
with_items:
- u1604
- u1804
- u2004
- u2104
- f33
- f34
- f35
- alp311
- alp312
- alp313
- alp314
- ubi8
- deb11

##############################################################
# Start the containers #
# If startallcontainers is skipped, only start three of them #
# ignore_errors simplest way to ignore if already started #
# #
# TODO: Check if started rather than ignore error? #
# hard to 'docker_container_info depends on start time #
# TODO: Use a calculated value instead of 2 core/6Gb #
##############################################################

- name: Start Ubuntu 16.04 container if not already started
community.docker.docker_container:
name: U1604_2222
image: aqa_u1604
ports:
- "2222:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers
failed_when: false

- name: Start Ubuntu 18.04 container if not already started
community.docker.docker_container:
name: U1804_2223
image: aqa_u1804
ports:
- "2223:22"
cpus: 4.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers, startallcontainers
failed_when: false

- name: Start Ubuntu 20.04 container if not already started
community.docker.docker_container:
name: U2004_2224
image: aqa_u2004
ports:
- "2224:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers
failed_when: false

- name: Start Ubuntu 21.04 container if not already started
community.docker.docker_container:
name: U2104_2225
image: aqa_aqa_u2104u2004
ports:
- "2225:22"
cpus: 4.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers, startallcontainers
failed_when: false

- name: Start Ubuntu 22.04 container if not already started
command: docker run --restart unless-stopped -p 2226:22 --cpus=4.0 --memory=6G --detach --name U2204_2226 aqa_u2204
tags: startcontainers, startallcontainers
failed_when: false

- name: Start fedora 33 container if not already started
community.docker.docker_container:
name: f33.2227
image: aqa_f33
ports:
- "2227:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers
failed_when: false

- name: Start fedora 34 container if not already started
community.docker.docker_container:
name: f34.2232
image: aqa_f34
ports:
- "2232:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers
failed_when: false

- name: Start fedora 35 container if not already started
community.docker.docker_container:
name: f35.2233
image: aqa_f35
ports:
- "2233:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers
failed_when: false

- name: Start Alpine 3.11 container if not already started
community.docker.docker_container:
name: alp311.2228
image: aqa_alp311
ports:
- "2228:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers, startallcontainers
failed_when: false

- name: Start Alpine 3.12 container if not already started
community.docker.docker_container:
name: alp312.2229
image: aqa_alp312
ports:
- "2229:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers
failed_when: false

- name: Start Alpine 3.13 container if not already started
community.docker.docker_container:
name: alp313.2230
image: aqa_alp313
ports:
- "2230:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers
failed_when: false

- name: Start Alpine 3.14 container if not already started
community.docker.docker_container:
name: alp314.2231
image: aqa_alp314
ports:
- "2231:22"
cpus: 2.0
memory: 6G
state: started # Make sure container is presented (if not exist then start it)
restart: yes # Use restart to force a matching container to be stopped and restarted (if exist then restart it)
detach: yes
tags: startcontainers
failed_when: false

- name: Start UBI8 container if not already started
command: docker run --restart unless-stopped -p 2235:22 --cpus=2.0 --memory=6G --detach --name ubi8.2235 aqa_ubi8
tags: startcontainers
failed_when: false

- name: Start Deb11 container if not already started
command: docker run --restart unless-stopped -p 2211:22 --cpus=2.0 --memory=6G --detach --name deb11.2211 aqa_deb11
tags: startcontainers
failed_when: false

# lineinfile does not work here - similar to the operation in /var/log in adopt_etc
# lineinfile: path /proc/sys/kernel/core_pattern state: present: regexp: . line: core.%p
# therefore the following section wil not become live prior to a reboot
Expand Down

0 comments on commit b26a406

Please sign in to comment.