-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow specifying python and ansible versions per component
- Loading branch information
Showing
4 changed files
with
70 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
- name: "Set python version for component {{ item.name }}" | ||
ansible.builtin.set_fact: | ||
python_version: "{{ item.python_version | default('3.10') }}" | ||
|
||
- name: "Set remote ansible version for component {{ item.name }}" | ||
ansible.builtin.set_fact: | ||
remote_ansible_version: "{{ item.remote_ansible_version | default('9.1.0') }}" | ||
|
||
- name: Setup ansible | ||
ansible.builtin.include_tasks: _setup_ansible.yml | ||
|
||
- name: Test the component by executing it using ansible on the workspace | ||
ansible.builtin.command: > | ||
ansible-playbook -c local -v -b {{ remote_plugin.arguments }} | ||
--extra-vars='ansible_python_interpreter={{ ansible_interpreter }}' | ||
--extra-vars='{{ remote_plugin.parameters }}' | ||
/rsc/plugins/{{ item.name }}/{{ item.path }} | ||
register: ansible_on_workspace | ||
changed_when: "ansible_on_workspace.stdout_lines is not defined or 'changed=0' not in ansible_on_workspace.stdout_lines[-1]" | ||
vars: | ||
ansible_interpreter: "{{ python_location }}" | ||
remote_plugin: | ||
script_type: Ansible PlayBook | ||
arguments: -i 127.0.0.1, --skip-tags {{ ansible_skip_tags | join(',') }} | ||
parameters: "{{ item.parameters | default({}) | to_json }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
- name: Install Python and Ansible for Ubuntu | ||
when: ansible_distribution == 'Ubuntu' | ||
block: | ||
|
||
- name: Set deadsnakes key download location | ||
ansible.builtin.set_fact: | ||
key_location: /usr/share/keyrings/deadsnakes.asc | ||
|
||
- name: Download deadsnakes key | ||
ansible.builtin.get_url: | ||
url: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf23c5a6cf475977595c89f51ba6932366a755776 | ||
dest: "{{ key_location }}" | ||
when: ansible_pkg_mgr == 'apt' | ||
|
||
- name: Add deadsnakes repo | ||
apt_repository: | ||
repo: "deb [signed-by={{ key_location }}] https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu {{ ansible_distribution_release }} main" | ||
state: present | ||
filename: deadsnakes | ||
|
||
- name: Install python | ||
apt: | ||
pkg: | ||
- "python{{ python_version }}" | ||
- "python{{ python_version }}-venv" | ||
state: present | ||
|
||
- name: Install ansible | ||
pip: | ||
name: "ansible=={{ remote_ansible_version }}" | ||
virtualenv: "/root/ansible_env{{ python_version }}" | ||
virtualenv_command: "python{{ python_version }} -m venv" | ||
|
||
- name: Set python location | ||
ansible.builtin.set_fact: | ||
python_location: "/root/ansible_env{{ python_version }}/bin/python3" | ||
Check failure on line 37 in _setup_ansible.yml GitHub Actions / Ansible Lintyaml[new-line-at-end-of-file]
Check failure on line 37 in _setup_ansible.yml GitHub Actions / Ansible Lintyaml[new-line-at-end-of-file]
Check failure on line 37 in _setup_ansible.yml GitHub Actions / Ansible Lintyaml[new-line-at-end-of-file]
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
gather_facts: false | ||
gather_facts: true | ||
tasks: | ||
- name: Debug -- list all components to be executed | ||
ansible.builtin.debug: | ||
msg: "{{ item.name }}" | ||
with_items: "{{ lookup('env', 'components') }}" | ||
|
||
- name: Test the component by executing it using ansible on the workspace | ||
ansible.builtin.command: > | ||
ansible-playbook -c local -v -b {{ remote_plugin.arguments }} --extra-vars='{{ remote_plugin.parameters }}' /rsc/plugins/{{ item.name}}/{{ item.path }} | ||
register: ansible_on_workspace | ||
changed_when: "ansible_on_workspace.stdout_lines is not defined or 'changed=0' not in ansible_on_workspace.stdout_lines[-1]" | ||
vars: | ||
remote_plugin: | ||
script_type: Ansible PlayBook | ||
arguments: -i 127.0.0.1, --skip-tags {{ ansible_skip_tags | join(',') }} | ||
parameters: "{{ item.parameters | default({}) | to_json }}" | ||
- name: Run component | ||
ansible.builtin.include_tasks: _run_component.yml | ||
with_items: "{{ lookup('env', 'components') }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters