Skip to content

Commit

Permalink
SLES15 enablement (elastic#2007)
Browse files Browse the repository at this point in the history
* SLES15 enablement

* fix: set ansible_user depending on OS

* fix: proper vars path

* fix: rename SLES distribution file

* fix: read distribution vars dynamically with include_vars

* fix: keep original behaviour for installing the stack on Debian

* fix: set vars correctly

* chore: debug ansible user

* Update .ci/.e2e-tests.yaml

Co-authored-by: Victor Martinez <[email protected]>

* Update .ci/ansible/vars/SLES.yml

Co-authored-by: Adam Stokes <[email protected]>

* Update .ci/ansible/playbook.yml

Co-authored-by: Victor Martinez <[email protected]>

* Fix package install for distro, update include_vars for all tasks

Signed-off-by: Adam Stokes <[email protected]>

* fix path to vars

Signed-off-by: Adam Stokes <[email protected]>

* try with ansible_playbook_vars_root

Signed-off-by: Adam Stokes <[email protected]>

* try var_files

Signed-off-by: Adam Stokes <[email protected]>

* typo

Signed-off-by: Adam Stokes <[email protected]>

* use full path and fix quoting

Signed-off-by: Adam Stokes <[email protected]>

* use include_vars

Signed-off-by: Adam Stokes <[email protected]>

* make include_vars first in task list for each block

Signed-off-by: Adam Stokes <[email protected]>

* dont include_vars on localhost execution

Signed-off-by: Adam Stokes <[email protected]>

* remove conflicting statements

Signed-off-by: Adam Stokes <[email protected]>

* have e2e-tests.yaml drive the login information

Signed-off-by: Adam Stokes <[email protected]>

* fix update cache on debian based systems

Signed-off-by: Adam Stokes <[email protected]>

* fix permission on output directory

Signed-off-by: Adam Stokes <[email protected]>

* fix group ownership in create test script

Signed-off-by: Adam Stokes <[email protected]>

* better os detection in ansible

Signed-off-by: Adam Stokes <[email protected]>

* fix chown in jenkinsfile

Signed-off-by: Adam Stokes <[email protected]>

Co-authored-by: Manuel de la Peña <[email protected]>
Co-authored-by: Adam Stokes <[email protected]>
Co-authored-by: Victor Martinez <[email protected]>
  • Loading branch information
4 people committed Jan 19, 2022
1 parent d1f1c28 commit 199ceb3
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 29 deletions.
10 changes: 10 additions & 0 deletions .ci/.e2e-tests-for-elastic-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@ PLATFORMS:
stack:
image: "ami-0d90bed76900e679a"
instance_type: "c5.4xlarge"
username: admin
helm:
image: "ami-0d90bed76900e679a"
instance_type: "c5.2xlarge"
username: admin
fleet_arm64:
image: "ami-06dac44ad759182bd"
instance_type: "a1.large"
username: admin
fleet_amd64:
image: "ami-0d90bed76900e679a"
instance_type: "c5.4xlarge"
username: admin
fleet_sles15:
image: "ami-0f7cb53c916a75006"
instance_type: "c5.4xlarge"
username: ec2-user
fleet_elastic_pkg:
image: "ami-0d90bed76900e679a"
instance_type: "c5.4xlarge"
username: admin
kubernetes_autodiscover:
image: "ami-0d90bed76900e679a"
instance_type: "c5.4xlarge"
username: admin

SUITES:
- suite: "fleet"
Expand Down
12 changes: 11 additions & 1 deletion .ci/.e2e-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,31 @@ PLATFORMS:
stack:
image: "ami-0d90bed76900e679a"
instance_type: "c5.4xlarge"
username: admin
helm:
image: "ami-0d90bed76900e679a"
instance_type: "c5.2xlarge"
username: admin
fleet_arm64:
image: "ami-06dac44ad759182bd"
instance_type: "a1.large"
username: admin
fleet_amd64:
image: "ami-0d90bed76900e679a"
instance_type: "c5.4xlarge"
username: admin
fleet_sles15:
image: "ami-0f7cb53c916a75006"
instance_type: "c5.4xlarge"
username: ec2-user
fleet_elastic_pkg:
image: "ami-0d90bed76900e679a"
instance_type: "c5.4xlarge"
username: admin
kubernetes_autodiscover:
image: "ami-0d90bed76900e679a"
instance_type: "c5.4xlarge"
username: admin

SUITES:
- suite: "helm"
Expand All @@ -35,7 +45,7 @@ SUITES:
scenarios:
- name: "Fleet"
tags: "fleet_mode_agent"
platforms: ["fleet_arm64", "fleet_amd64"]
platforms: ["fleet_arm64", "fleet_amd64", "fleet_sles15"]
- name: "Integrations"
tags: "integrations"
platforms: ["fleet_arm64", "fleet_amd64"]
Expand Down
14 changes: 7 additions & 7 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ pipeline {

ansible(stackWorkspace,
env.RUN_ID.split('-')[0],
"-t provision-stack --extra-vars=\"nodeLabel=stack nodeImage=${stackMachine.image} nodeInstanceType=${stackMachine.instance_type}\"")
"-t provision-stack --extra-vars=\"nodeUser=${stackMachine.username} nodeLabel=stack nodeImage=${stackMachine.image} nodeInstanceType=${stackMachine.instance_type}\"")

// Must be gathered after deployment as the public IP is known at that time
def stackRunner = getNodeIp(stackWorkspace, 'stack')
Expand All @@ -213,7 +213,7 @@ pipeline {
ansible(
stackWorkspace,
env.RUN_ID.split('-')[0],
"-i \"${stackRunner.ip},\" -t setup-stack --extra-vars=\"nodeLabel=stack nodeImage=${stackMachine.image} nodeInstanceType=${stackMachine.instance_type}\""
"-i \"${stackRunner.ip},\" -t setup-stack --extra-vars=\"nodeLabel=stack nodeUser=${stackMachine.username} nodeImage=${stackMachine.image} nodeInstanceType=${stackMachine.instance_type}\""
)
}

Expand Down Expand Up @@ -270,7 +270,7 @@ pipeline {
def stackMachine = getMachineInfo(stackWorkspace, 'stack')
ansible(stackWorkspace,
env.RUN_ID.split('-')[0],
"-t destroy --extra-vars=\"nodeLabel=stack nodeImage=${stackMachine.image} nodeInstanceType=${stackMachine.instance_type}\"")
"-t destroy --extra-vars=\"nodeLabel=stack nodeUser=${stackMachine.username} nodeImage=${stackMachine.image} nodeInstanceType=${stackMachine.instance_type}\"")
}
}
}
Expand Down Expand Up @@ -503,14 +503,14 @@ def generateFunctionalTestStep(Map args = [:]){
// Start node, capture ip address
ansible("${env.WORKSPACE}",
runId,
"-t start-node --extra-vars=\"stackRunner=${stackRunner.ip} nodeLabel=${platform} nodeImage=${machine.image} nodeInstanceType=${machine.instance_type}\"")
"-t start-node --extra-vars=\"stackRunner=${stackRunner.ip} nodeUser=${machine.username} nodeLabel=${platform} nodeImage=${machine.image} nodeInstanceType=${machine.instance_type}\"")

def testRunner = getNodeIp("${env.WORKSPACE}", platform)

// Configure node for testing
ansible("${env.WORKSPACE}",
runId,
"-i \"${testRunner.ip},\" -t setup-node --extra-vars=\"stackRunner=${stackRunner.ip} nodeLabel=${platform} nodeImage=${machine.image} nodeInstanceType=${machine.instance_type}\"")
"-i \"${testRunner.ip},\" -t setup-node --extra-vars=\"stackRunner=${stackRunner.ip} nodeUser=${machine.username} nodeLabel=${platform} nodeImage=${machine.image} nodeInstanceType=${machine.instance_type}\"")

sshexec("${env.WORKSPACE}",
testRunner,
Expand All @@ -522,15 +522,15 @@ def generateFunctionalTestStep(Map args = [:]){
sh "mkdir -p outputs/${testRunner.ip} || true"
sshexec("${env.WORKSPACE}",
testRunner,
"""sudo chown ${testRunner.user}:${testRunner.user} -R /home/${testRunner.user}/e2e-testing/outputs """)
"""sudo chown ${testRunner.user} -R /home/${testRunner.user}/e2e-testing/outputs """)
scpr("${env.WORKSPACE}",
testRunner,
"e2e-testing/outputs/TEST-*${runId}*.xml",
"outputs/${testRunner.ip}/.")
sh "ls -l outputs/${testRunner.ip}"
ansible("${env.WORKSPACE}",
runId,
"-t destroy --extra-vars=\"nodeLabel=${platform} nodeImage=${machine.image} nodeInstanceType=${machine.instance_type}\"")
"-t destroy --extra-vars=\"nodeLabel=${platform} nodeUser=${machine.username} nodeImage=${machine.image} nodeInstanceType=${machine.instance_type}\"")
junit allowEmptyResults: true,
keepLongStdio: true,
testResults: "outputs/${testRunner.ip}/TEST-*${runId}*.xml"
Expand Down
22 changes: 12 additions & 10 deletions .ci/ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
hosts: localhost
gather_facts: no
vars:
ansible_user: admin
ansible_user: "{{nodeUser}}"
tasks:
- name: Setup nodes
include_tasks: tasks/runners.yml
Expand All @@ -14,7 +14,7 @@
hosts: localhost
gather_facts: no
vars:
ansible_user: admin
ansible_user: "{{nodeUser}}"
tasks:
- name: Teardown Test Runners (AWS)
include_tasks: tasks/teardown.yml
Expand All @@ -27,6 +27,10 @@
become: True
tags:
- setup-stack
pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
roles:
- role: geerlingguy.docker
docker_daemon_options:
Expand All @@ -37,10 +41,8 @@
vars:
golang_version: 1.16.3
vars:
ansible_user: admin
ansible_user: "{{nodeUser}}"
ansible_python_interpreter: /usr/bin/python3
pre_tasks:
- apt: {update_cache: yes}
tasks:
- name: Install deps
include_tasks: tasks/install_deps.yml
Expand All @@ -62,7 +64,6 @@
include_tasks: tasks/copy_test_files.yml
tags:
- setup-stack

- name: Start stack
shell: |
sed -i '' -e 's,http://elasticsearch,http://{{inventory_hostname}},g' /home/{{ansible_user}}/e2e-testing/cli/config/compose/profiles/fleet/default/kibana.config.yml
Expand All @@ -78,6 +79,10 @@
become: True
tags:
- setup-node
pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
roles:
- role: geerlingguy.docker
docker_daemon_options:
Expand All @@ -93,10 +98,8 @@
vars:
golang_version: 1.16.3
vars:
ansible_user: admin
ansible_python_interpreter: /usr/bin/python3
pre_tasks:
- apt: {update_cache: yes}
ansible_user: "{{nodeUser}}"
tasks:
- name: Install deps
include_tasks: tasks/install_deps.yml
Expand All @@ -108,7 +111,6 @@
tags:
- setup-node
- copy-source

- name: Configure test script
include_tasks: tasks/setup_test_script.yml
tags:
Expand Down
2 changes: 1 addition & 1 deletion .ci/ansible/tasks/copy_test_files.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
- name: Create outputs dir
become: no
ansible.builtin.file:
path: "/home/{{ansible_user}}/e2e-testing/outputs"
state: directory
mode: '0755'
owner: "{{ansible_user}}"
group: "{{ansible_user}}"

- name: Copy source code
become: no
Expand Down
44 changes: 37 additions & 7 deletions .ci/ansible/tasks/install_deps.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
---
- name: Update cache
shell: |
sudo apt-get update
- name: Install dependencies
ansible.builtin.package:
- name: Install dependencies (Debian/Ubuntu)
apt:
name:
- rsync
- wget
- build-essential
state: latest
use: apt
update_cache: yes
register: package_install_res
retries: 5
until: package_install_res is success
when: ansible_pkg_mgr == 'apt' or ansible_distribution in ["Debian", "Ubuntu"]

- name: Install dependencies (SUSE)
zypper:
name:
- autoconf
- bison
- flex
- gcc
- gcc-c++
- kernel-default-devel
- make
- m4
- rsync
- wget
state: present
when: ansible_pkg_mgr == 'zypper' or ansible_os_family == "Suse"

- name: Install dependencies (CentOS)
ansible.builtin.package:
name:
- autoconf
- bison
- flex
- gcc
- gcc-c++
- kernel-devel
- make
- m4
- patch
- rsync
- wget
state: latest
when: ansible_distribution in ["Fedora", "RedHat", "CentOS"]
2 changes: 1 addition & 1 deletion .ci/ansible/tasks/runners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
become: no
lineinfile:
state: present
line: "- admin@{{addr.public_ip}}"
line: "- {{nodeUser}}@{{addr.public_ip}}"
insertafter: EOF
dest: "{{workspace}}/{{nodeLabel}}-sshhosts"
create: yes
Expand Down
3 changes: 1 addition & 2 deletions .ci/ansible/tasks/setup_test_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- "export FLEET_URL=http://{{stackRunner}}:8220"
- "export SKIP_PULL=1"

when: "'fleet_arm64' == nodeLabel or 'fleet_amd64' == nodeLabel"
when: "'fleet_arm64' == nodeLabel or 'fleet_amd64' == nodeLabel or 'fleet_sles15' == nodeLabel"

- name: Extend environment for Fleet with elastic-package testing
lineinfile:
Expand Down Expand Up @@ -72,7 +72,6 @@
become: no
copy:
owner: "{{ansible_user}}"
group: "{{ansible_user}}"
mode: '0777'
dest: "/home/{{ansible_user}}/e2e-testing/.ci/scripts/functional-test.sh"
content: |
Expand Down

0 comments on commit 199ceb3

Please sign in to comment.