Skip to content

Commit

Permalink
Ansible module name adjustments
Browse files Browse the repository at this point in the history
Ansible module name adjustments to fix DEPRECATION WARNINGs: ocp-power-automation#68
Signed-off-by: Niklas Vosskoetter [email protected]
  • Loading branch information
neikei committed Apr 18, 2021
1 parent 10fec74 commit 8e9cf22
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 95 deletions.
2 changes: 1 addition & 1 deletion playbooks/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
hosts: bastion[0]
tasks:
- name: Wait for bootstrap complete
shell: "openshift-install wait-for bootstrap-complete --log-level {{ log_level }}"
ansible.builtin.shell: "openshift-install wait-for bootstrap-complete --log-level {{ log_level }}"
args:
chdir: "{{ workdir }}"

Expand Down
4 changes: 2 additions & 2 deletions playbooks/roles/nodes-config/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

# Wait at least 30m for node connection
- name: Check connection
wait_for_connection:
ansible.builtin.wait_for_connection:
delay: 15
connect_timeout: 15
timeout: "{{ node_connection_timeout }}"

- name: Configure node
shell: |
ansible.builtin.shell: |
if lsmod|grep -q 'ibmveth'; then
sudo sysctl -w net.ipv4.route.min_pmtu=1450;
sudo sysctl -w net.ipv4.ip_no_pmtu_disc=1;
Expand Down
6 changes: 3 additions & 3 deletions playbooks/roles/ocp-config/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
# handlers file for ansible-squid
- name: restart squid
service:
ansible.builtin.service:
name: squid
state: restarted
daemon_reload: yes
enabled: yes

- name: restart firewalld
service:
ansible.builtin.service:
name: firewalld
state: restarted
enabled: yes

- name: restart chrony
service:
ansible.builtin.service:
name: chronyd
state: restarted
daemon_reload: yes
Expand Down
14 changes: 7 additions & 7 deletions playbooks/roles/ocp-config/tasks/chrony.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
state: present

- name: Open NTP port on firewall
firewalld:
ansible.posix.firewalld:
service: ntp
permanent: yes
immediate: yes
state: enabled

- name: Configure chrony to synchronize with ntp servers
lineinfile:
ansible.builtin.lineinfile:
path: /etc/chrony.conf
regexp: '^server {{ item.server }} '
state: present
Expand All @@ -26,7 +26,7 @@
- restart chrony

- name: Remove Chrony default pool when ntp server are used
lineinfile:
ansible.builtin.lineinfile:
path: /etc/chrony.conf
regexp: '^pool .*\.rhel\.pool\.ntp\.org'
state: absent
Expand All @@ -38,7 +38,7 @@
- restart chrony

- name: Allow local stratum in chrony.conf on bastion
lineinfile:
ansible.builtin.lineinfile:
path: /etc/chrony.conf
regexp: '^local stratum'
state: present
Expand All @@ -49,7 +49,7 @@
- restart chrony

- name: Allow Cluster Network in chrony.conf on bastion
lineinfile:
ansible.builtin.lineinfile:
path: /etc/chrony.conf
regexp: '^allow'
state: present
Expand All @@ -64,14 +64,14 @@
- restart chrony

- name: Create chrony dropin directory
file:
ansible.builtin.file:
path: /etc/systemd/system/chronyd.service.d
state: directory
mode: 0755
become: true

- name: Copy restart conf file to the chrony dropin directory
copy:
ansible.builtin.copy:
src: ../files/restart.conf
dest: /etc/systemd/system/chronyd.service.d/restart.conf
notify:
Expand Down
6 changes: 3 additions & 3 deletions playbooks/roles/ocp-config/tasks/dhcpd_update.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
# Update dhcpd config to not deny unknown clients and use only static entries
- name: Find DHCP pool block
shell: grep 'pool {' /etc/dhcp/dhcpd.conf
ansible.builtin.shell: grep 'pool {' /etc/dhcp/dhcpd.conf
ignore_errors: yes
register: dhcp_pool

- name: Update DHCP server config
when: dhcp_pool.rc == 0
block:
- name: Remove pool, range and deny statements
shell: |
ansible.builtin.shell: |
sed -i.bak '/pool {/d' /etc/dhcp/dhcpd.conf
sed -i '/range /d' /etc/dhcp/dhcpd.conf
sed -i '$d' /etc/dhcp/dhcpd.conf
Expand All @@ -18,7 +18,7 @@
warn: false

- name: restart dhcpd
service:
ansible.builtin.service:
name: dhcpd
state: restarted
enabled: yes
20 changes: 10 additions & 10 deletions playbooks/roles/ocp-config/tasks/extract.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---

- name: Set tools directory path
set_fact:
ansible.builtin.set_fact:
tools_dir: "~/ocp4_tools"

- name: Create tools directory
file:
ansible.builtin.file:
path: "{{ tools_dir }}"
state: "{{ item }}"
mode: '0755'
Expand All @@ -15,50 +15,50 @@
- name: local-registry service
block:
- name: Restart local-registry service
service:
ansible.builtin.service:
name: local-registry
state: restarted

- name: Wait for local-registry to restart
wait_for:
ansible.builtin.wait_for:
timeout: 15
when: enable_local_registry

- name: Extract OCP4 tools from release image ( local-registry )
when: enable_local_registry
shell: |
ansible.builtin.shell: |
oc adm release extract --tools {{ release_image_override }} --registry-config='{{ ansible_env.HOME }}/.openshift/pull-secret-updated'
args:
chdir: "{{ tools_dir }}"

- name: Create pull-secret file
when: not enable_local_registry
copy:
ansible.builtin.copy:
content: "{{ install_config.pull_secret }}"
dest: "{{ tools_dir }}/pull-secret"

- name: Extract OCP4 tools from release image
when: not enable_local_registry
shell: |
ansible.builtin.shell: |
oc adm release extract --tools {{ release_image_override }} --registry-config='pull-secret'
args:
chdir: "{{ tools_dir }}"

- name: Find archive packages
find:
ansible.builtin.find:
paths: "{{ tools_dir }}"
patterns: "openshift-*.tar.gz"
register: find_result

- name: Unarchive OCP4 tool files
unarchive:
ansible.builtin.unarchive:
src: "{{ item.path }}"
dest: /usr/local/bin
remote_src: yes
with_items: "{{ find_result.files }}"

- name: Remove tools directory
file:
ansible.builtin.file:
path: "{{ tools_dir }}"
state: "{{ item }}"
mode: '0755'
Expand Down
36 changes: 18 additions & 18 deletions playbooks/roles/ocp-config/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
# tasks file for ocp4 config

- name: Update DHCP server config for shared network
import_tasks: dhcpd_update.yaml
ansible.builtin.import_tasks: dhcpd_update.yaml
when: dhcp_shared_network is defined and dhcp_shared_network

- name: Setup Squid proxy server
import_tasks: squid.yaml
ansible.builtin.import_tasks: squid.yaml
when: setup_squid_proxy

- name: Extract OCP4 tools
import_tasks: extract.yaml
ansible.builtin.import_tasks: extract.yaml
when: release_image_override != ""

- name: Setup time synchronisation with Chrony
import_tasks: chrony.yaml
ansible.builtin.import_tasks: chrony.yaml
when: chronyconfig.enabled

- name: OCP config
when: inventory_hostname in groups['bastion'][0]
block:
- name: Skip config if install workdir exist
stat:
ansible.builtin.stat:
path: "{{ workdir }}"
register: dir_status

- meta: end_play
when: dir_status.stat.exists

- name: Setup openshift workdir
file:
ansible.builtin.file:
path: "{{ workdir }}"
state: "{{ item }}"
mode: '0755'
Expand All @@ -38,46 +38,46 @@
- directory

- name: Generate install-config.yaml
template:
ansible.builtin.template:
src: ../templates/install-config.yaml.j2
dest: "{{ workdir }}/install-config.yaml"

- name: backup the install-config.yaml
copy:
ansible.builtin.copy:
src: "{{ workdir }}/install-config.yaml"
dest: "{{ workdir }}/install-config.yaml.back"
remote_src: yes
force: yes

- name: Generate manifest files
shell: "openshift-install create manifests --log-level {{ log_level }}"
ansible.builtin.shell: "openshift-install create manifests --log-level {{ log_level }}"
args:
chdir: "{{ workdir }}"

- name: Setup network configuration
template:
ansible.builtin.template:
src: ../templates/cluster-network-03-config.yml.j2
dest: "{{ workdir }}/manifests/cluster-network-03-config.yml"
when: cni_network_mtu is defined

- name: Remove the machine yaml files
file:
ansible.builtin.file:
path: "{{ item }}"
state: absent
with_fileglob:
- "{{ workdir }}/openshift/99_openshift-cluster-api_master-machines-*.yaml"
- "{{ workdir }}/openshift/99_openshift-cluster-api_worker-machineset-*.yaml"

- name: Make the control-plane un-schedulable
lineinfile:
ansible.builtin.lineinfile:
path: "{{ workdir }}/manifests/cluster-scheduler-02-config.yml"
regexp: '^(.*)mastersSchedulable: true'
line: '\1mastersSchedulable: False'
backrefs: yes
when: worker_count|int > 0

- name: Copy machineconfig files generated from helpernode
copy:
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ workdir }}/manifests"
remote_src: yes
Expand All @@ -86,28 +86,28 @@
when: chronyconfig.enabled

- name: Create ignition files
shell: "OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE={{ release_image_override }} openshift-install create ignition-configs --log-level {{ log_level }}"
ansible.builtin.shell: "OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE={{ release_image_override }} openshift-install create ignition-configs --log-level {{ log_level }}"
args:
chdir: "{{ workdir }}"

- name: Copy update_ignition_bootstrap
template:
ansible.builtin.template:
src: ../files/update_ignition_bootstrap.py
dest: /tmp/update_ignition_bootstrap.py
mode: '0755'

- name: Update bootstrap ignition
shell: "python3 /tmp/update_ignition_bootstrap.py"
ansible.builtin.shell: "python3 /tmp/update_ignition_bootstrap.py"
args:
chdir: "{{ workdir }}"

- name: Host ignition files
copy:
ansible.builtin.copy:
src: "{{ item }}"
dest: /var/www/html/ignition/
mode: o+r
with_fileglob:
- "{{ workdir }}/*.ign"

- name: Best effort SELinux repair - Apache
shell: "restorecon -vR /var/www/html || true"
ansible.builtin.shell: "restorecon -vR /var/www/html || true"
12 changes: 6 additions & 6 deletions playbooks/roles/ocp-config/tasks/squid.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---

- name: Install Squid package
package:
ansible.builtin.package:
name: squid
state: present

- name: Configure Squid
template:
ansible.builtin.template:
src: etc/squid/squid.conf.j2
dest: /etc/squid/squid.conf
owner: root
Expand All @@ -17,7 +17,7 @@
- restart squid

- name: Add Squid to firewall
firewalld:
ansible.posix.firewalld:
service: squid
permanent: true
state: enabled
Expand All @@ -26,18 +26,18 @@
- restart firewalld

- name: Set proxy details
set_fact:
ansible.builtin.set_fact:
squid_proxy_url: "http://{{ bastion_vip | default(ansible_host) }}:{{ squid_http_port }}"

- name: Create squid dropin directory
file:
ansible.builtin.file:
path: /etc/systemd/system/squid.service.d
state: directory
mode: 0755
become: true

- name: Copy restart conf file to the squid dropin directory
copy:
ansible.builtin.copy:
src: ../files/restart.conf
dest: /etc/systemd/system/squid.service.d/restart.conf
notify:
Expand Down
Loading

0 comments on commit 8e9cf22

Please sign in to comment.