Browse Source

First working version

Signed-off-by: Blagovest Petrov <blagovest@petrovs.info>
master
Blagovest Petrov 2 years ago
parent
commit
e59fcfa3c1
  1. 46
      README.md
  2. 0
      files/.gitkeep
  3. 47
      tasks/main.yml

46
README.md

@ -1,22 +1,51 @@
Role Name
ansible-rhel4
=========
A brief description of the role goes here.
Ansible support for EL4. Installs the last Python 2.7
Known issues:
* ansible.builtin.yum module doesn't work
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Add the following to `hosts`:
client_node ansible_python_interpreter=/opt/python2.7/bin/python2.7
The SSHD in EL4 supports only older algorithms. To login successfully in EL4 host, pass those options to the SSH client:
```
ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa -o KexAlgorithms=+diffie-hellman-group1-sha1
```
Example ~.ssh/config:
```
Host el4-host
HostName el4-host.acme.local
HostKeyAlgorithms=+ssh-rsa
PubkeyAcceptedKeyTypes=+ssh-rsa
KexAlgorithms=+diffie-hellman-group1-sha1
```
Also, disable gathering of facts the first time:
```
gather_facts: no
```
The script is using raw SCP command from the local host. It won't work with `--ask-pass`
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
ansible_rhel4_python_version: "2.7.18"
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
EL4 repository archive must work to install development packages.
Example Playbook
----------------
@ -24,8 +53,11 @@ Example Playbook
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
become: yes
gather_facts: no
ansible_python_interpreter=/opt/python2.7/bin/python2.7
roles:
- { role: username.rolename, x: 42 }
- { role: ansible-rhel4 }
License
-------
@ -34,5 +66,3 @@ BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

0
files/.gitkeep

47
tasks/main.yml

@ -1,18 +1,51 @@
---
# tasks file for ansible-rhel4
- name: "Remove 'redhat-lsb' package (BUG: https://bugs.centos.org/view.php?id=1547)"
ansible.builtin.raw: "rpm -e redhat-lsb || exit 0"
- name: Install development tools
ansible.builtin.raw: yum -y groupinstall "Development tools"
ansible.builtin.raw: "/usr/bin/yum -y groupinstall \"Development Tools\""
- name: Install dev dependencies
ansible.builtin.raw: "yum -y install {{ ansible_rhel4_dev_dependencies }}"
ansible.builtin.raw: "/usr/bin/yum -y install {{ item }}"
loop: "{{ ansible_rhel4_dev_dependencies }}"
- name: Download Python
ansible.builtin.raw: wget --no-check-certificate https://www.python.org/ftp/python/{{ ansible_rhel4_python_version }}/Python-2.7.18.tgz -O /tmp/Python2.7.tgz
- name: Download Python locally. EL4 doesn't support modern SSL
ansible.builtin.get_url:
url: "https://www.python.org/ftp/python/{{ ansible_rhel4_python_version }}/Python-{{ ansible_rhel4_python_version }}.tgz"
dest: "{{ role_path }}/files/Python2.7.tgz"
delegate_to: 127.0.0.1
- name: Copy Python 2.7 to the server{
local_action: "command scp {{ role_path }}/files/Python2.7.tgz {{ ansible_user }}@{{ ansible_host }}:/tmp/"
- name: Extract Python source
ansible.builtin.raw: tar -xvzf /tmp/Python2.7.tgz -C /opt/
ansible.builtin.raw: tar -xvzf /tmp/Python2.7.tgz -C /tmp/
- name: Make install directory for Python 2.7
ansible.builtin.raw: mkdir /opt/python2.7 || exit 0
- name: Execute Configure script for Python
ansible.builtin.raw: "cd /tmp/Python-{{ ansible_rhel4_python_version }} && ./configure --prefix=/opt/python2.7 --enable-shared"
- name: Make
ansible.builtin.raw: "cd /tmp/Python-{{ ansible_rhel4_python_version }} && make"
- name: Make altinstall
ansible.builtin.raw: "cd /tmp/Python-{{ ansible_rhel4_python_version }} && make altinstall"
# - name: Add Python to PATH
# ansible.builtin.raw: echo "export PATH=$PATH:/opt/python2.7/bin" >> /etc/profile
# - name: Add Python to LD_LIBRARY_PATH
# ansible.builtin.raw: echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/python2.7/lib" >> /etc/profile
- name: Create ldconfig conf for Python 2.7
ansible.builtin.raw: echo /opt/python2.7/lib >> /etc/ld.so.conf.d/python27.conf
- name: Run ldconfig
ansible.builtin.raw: ldconfig
- name: Remove Python source archive
ansible.builtin.raw: rm-rf /tmp/Python2.7.tgz
- name: Test ansible on the host
ansible.builtin.ping:

Loading…
Cancel
Save