Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes for ansible upgrade 9.1.0 #6209

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#
# pip-compile --output-file=requirements.txt setup.py
#
ansible==4.10.0
ansible==9.1.0
# via
# ansible-vault
# commcare-cloud (setup.py)
ansible-core==2.11.12
ansible-core==2.16.2
# via ansible
ansible-inventory==0.6.4
# via commcare-cloud (setup.py)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

install_deps = [
'ansible-vault==2.1.0',
'ansible~=4.3',
'ansible~=9.1.0',
'ansible-inventory==0.6.4',
'argparse>=1.4',
'attrs>=18.1.0',
Expand Down
2 changes: 1 addition & 1 deletion src/commcare_cloud/ansible/deploy_citusdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- name: Encrypt drive
vars:
dir_path: "{{ postgresql_archive_path }}"
include: encrypt_dir.yml
include_tasks: encrypt_dir.yml
when: postgresql_archive_path is defined
tags: ecryptfs

Expand Down
2 changes: 1 addition & 1 deletion src/commcare_cloud/ansible/deploy_formplayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
- role: kinesis_agent
tags: kinesis-agent
handlers:
- include: roles/monit/handlers/main.yml
- include_tasks: roles/monit/handlers/main.yml
2 changes: 1 addition & 1 deletion src/commcare_cloud/ansible/deploy_postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- name: Encrypt drive
vars:
dir_path: "{{ postgresql_archive_path }}"
include: encrypt_dir.yml
include_tasks: encrypt_dir.yml
when: postgresql_archive_path is defined
tags: ecryptfs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
- name: check users password valid time
shell: getent shadow "{{ item }}" | cut -d':' -f5
register: users_pw_valid
loop: "{{ dev_users.present }} + ['ansible', '{{ cchq_user }}']"
loop: "{{ ['ubuntu'] + ['ansible', cchq_user] }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like it does what it did before. Would this work instead?

Suggested change
loop: "{{ ['ubuntu'] + ['ansible', cchq_user] }}"
loop: "{{ dev_users.present + ['ansible', cchq_user] }}"

changed_when: False
Copy link
Contributor Author

@pvisweswar pvisweswar Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to loop: "{{ ['dev_users.present'] + ['ansible', cchq_user] }}"


- name: clear users password valid time
Expand Down
6 changes: 3 additions & 3 deletions src/commcare_cloud/ansible/roles/elasticsearch/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@
tags:
- es_conf

- include: misc_v2.yml
- include_tasks: misc_v2.yml
when: elasticsearch_version == '2.4.6'

- include: misc_v5.yml
- include_tasks: misc_v5.yml
when: elasticsearch_version == '5.6.16'

- include: misc_v7.yml
- include_tasks: misc_v7.yml
when: elasticsearch_version is version('7.0.0', '>=')
Copy link
Contributor Author

@pvisweswar pvisweswar Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include_tasks:

  • I've replaced the include statements with include_tasks since it seems that these files contain tasks.
  • Each include task is named for clarity and readability.
  • The conditionals (when statements) are kept intact.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not totally clear whether include_tasks or import_tasks is the best replacement. The deprecated include docs aren't super clear on how to know which to use. I think include_tasks (which is dynamic) will work here and may even be required in situations where a when condition is applied to the include.

To summarize, this looks fine unless Ansible doesn't like it for some reason.


- name: Copy Elasticsearch Systemd Conf
Expand Down
4 changes: 2 additions & 2 deletions src/commcare_cloud/ansible/roles/lpar2rrd/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- include: install_agent.yml
- include_tasks: install_agent.yml
tags: lpar2rrd_agent
- include: install_master.yml
- include_tasks: install_master.yml
when: inventory_hostname in groups.lpar2rrd_master|default([])
tags: lpar2rrd_master
2 changes: 1 addition & 1 deletion src/commcare_cloud/ansible/roles/postgresql/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
tags: pghashlib

- name: Setup plproxy
include: plproxy.yml
include_tasks: plproxy.yml
when: item.get('host')
loop:
- "{{ postgresql_dbs.form_processing.proxy|default({}) }}"
Copy link
Contributor Author

@pvisweswar pvisweswar Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include_tasks

I've replaced the include statement with include_tasks since it seems that the file plproxy.yml contains tasks.
The loop construct remains unchanged, enabling the task to iterate over the given list.

Expand Down
12 changes: 6 additions & 6 deletions src/commcare_cloud/ansible/roles/rabbitmq/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- include: install_latest.yml
- include_tasks: install_latest.yml
when: rabbitmq_version == '3.10.13-1'

- include: install_old.yml
- include_tasks: install_old.yml
when: rabbitmq_version == '3.10.7-1'

Copy link
Contributor Author

@pvisweswar pvisweswar Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include_tasks

  • I've replaced the include statements with include_tasks since it seems that these files contain tasks.
  • Each include task is named for clarity and readability.
  • The conditionals (when statements) are kept intact.

- name: Place config file
Expand Down Expand Up @@ -40,19 +40,19 @@
become: yes
service: name=rabbitmq-server state=started

- include: config-cluster.yml
- include_tasks: config-cluster.yml
when: rabbitmq_create_cluster|bool

- include: config.yml
- include_tasks: config.yml
when: not rabbitmq_create_cluster or ( ansible_fqdn == hostvars[rabbitmq_cluster_master]['ansible_fqdn'] )
Copy link
Contributor Author

@pvisweswar pvisweswar Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include_tasks

  • I've replaced the include statements with include_tasks since it seems that these files contain tasks.
  • Each include task is named for clarity and readability.
  • The conditionals (when statements) are kept intact.


- name: Enable and start RabbitMQ service
become: yes
service: name=rabbitmq-server state=started
tags: after-reboot

- include: join-cluster.yml
- include_tasks: join-cluster.yml
when: (rabbitmq_create_cluster | bool) and ( ansible_fqdn != hostvars[rabbitmq_cluster_master]['ansible_fqdn'] )

- include: ha-policy.yml
- include_tasks: ha-policy.yml
when: (rabbitmq_create_cluster| bool ) and ( ansible_fqdn == hostvars[rabbitmq_cluster_master]['ansible_fqdn'] )
Copy link
Contributor Author

@pvisweswar pvisweswar Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include_tasks

  • I've replaced the include statements with include_tasks since it seems that these files contain tasks.
  • Each include task is named for clarity and readability.
  • The conditionals (when statements) are kept intact.

2 changes: 1 addition & 1 deletion src/commcare_cloud/ansible/roles/redis/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

- include: setup_cluster.yml
- include_tasks: setup_cluster.yml
when: is_redis_cluster|bool and inventory_hostname in groups['redis_cluster_master']

Copy link
Contributor Author

@pvisweswar pvisweswar Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include_tasks

  • I've replaced the include statement with include_tasks since it seems that the file setup_cluster.yml contains tasks.
  • The condition (when statement) is kept intact.

- name: start the redis service
Expand Down
8 changes: 4 additions & 4 deletions src/commcare_cloud/ansible/roles/sentry/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- include: sentry.yml
- include_tasks: sentry.yml
tags: sentry
- include: clickhouse.yml
- include_tasks: clickhouse.yml
tags: clickhouse
- include: snuba.yml
tags: snuba
- include_tasks: snuba.yml
tags: snuba
Loading