Skip to content

Commit 9faac97

Browse files
committed
Use bootstrap user & add condition for rocky only
1 parent ab8c0ee commit 9faac97

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed
Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
1-
- name: Install Python 3.12 to hosts
1+
- name: Install Python 3.12 to hosts (Rocky)
22
hosts: all
33
become: true
4+
vars:
5+
ansible_user: cloud-user
46
tasks:
5-
- name: Install Python 3.12
6-
ansible.builtin.dnf:
7-
name: python3.12
8-
state: latest
7+
- name: Ensure Python 3.12 is default interpreter
8+
when: ansible_facts.os_family == 'RedHat'
9+
block:
10+
- name: Install Python 3.12
11+
ansible.builtin.dnf:
12+
name: python3.12
13+
state: latest
914

10-
- name: Edit symlinks to make Python 3.12 default (/usr/bin)
11-
ansible.builtin.file:
12-
src: /usr/bin/python3.12
13-
dest: /usr/bin/python3
14-
owner: root
15-
group: root
16-
state: link
17-
force: true
15+
- name: Edit symlinks to make Python 3.12 default (/usr/bin)
16+
ansible.builtin.file:
17+
src: /usr/bin/python3.12
18+
dest: /usr/bin/python3
19+
owner: root
20+
group: root
21+
state: link
22+
force: true
1823

19-
- name: Edit symlinks to make Python 3.12 default (/bin)
20-
ansible.builtin.file:
21-
src: /bin/python3.12
22-
dest: /bin/python3
23-
owner: root
24-
group: root
25-
state: link
26-
force: true
24+
- name: Edit symlinks to make Python 3.12 default (/bin)
25+
ansible.builtin.file:
26+
src: /bin/python3.12
27+
dest: /bin/python3
28+
owner: root
29+
group: root
30+
state: link
31+
force: true
2732

28-
- name: Verify Python version
29-
ansible.builtin.command: python3 --version
30-
register: python_version
33+
- name: Verify Python version
34+
ansible.builtin.command: python3 --version
35+
register: python_version
3136

32-
- name: Print Python version
33-
ansible.builtin.debug:
34-
var: python_version.stdout
35-
36-
- name: Ensure Python 3.12 pip
37-
ansible.builtin.command: python3 -m ensurepip
37+
- name: Print Python version
38+
ansible.builtin.debug:
39+
var: python_version.stdout
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/rocky9-python312.yml

0 commit comments

Comments
 (0)