diff --git a/defaults/main.yml b/defaults/main.yml index e2b638a..ab1b5ca 100755 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -6,10 +6,10 @@ shared_storage: false data_mount_root: /data ldap_user_home_directory: homedirs openldap_clientconfig: /etc/ldap.conf -#The ldif file +# The ldif file openldap_server_ldif: domain.ldif -openldap_server_dc: dc={{ ',dc='.join( openldap_server_domain_name.split('.') ) }} +openldap_server_dc: dc={{ ',dc='.join(openldap_server_domain_name.split('.')) }} openldap_server_bind_dn: cn=Manager,{{ openldap_server_dc }} diff --git a/tasks/afp_server.yml b/tasks/afp_server.yml index 2af7b4f..7924fe7 100644 --- a/tasks/afp_server.yml +++ b/tasks/afp_server.yml @@ -1,4 +1,8 @@ --- +- name: Wait for locks + ansible.builtin.include_tasks: + file: wait_for_locks.yml + - name: Install afpd required packages ansible.builtin.apt: name: "{{ afpd_pkgs }}" diff --git a/tasks/ldap_autofs_install.yml b/tasks/ldap_autofs_install.yml index c3dff96..8b6a12a 100644 --- a/tasks/ldap_autofs_install.yml +++ b/tasks/ldap_autofs_install.yml @@ -1,16 +1,20 @@ --- +- name: Wait for locks + ansible.builtin.include_tasks: + file: wait_for_locks.yml + - name: Install autofs packages and supporting ldap packages ansible.builtin.package: - name: "{{ openldap_autofs_packages }}" + name: autofs state: present update_cache: true when: - - openldap_server_enable_autofs + - openldap_server_enable_autofs | default(true) - name: Copy autofs defaults file ansible.builtin.template: src: autofs.j2 - dest: "{{ openldap_autofs_defaults_file }}" + dest: /etc/defaults/autofs mode: "0755" notify: - Restart AutoFS @@ -58,7 +62,6 @@ line: AuthorizedKeysCommandUser {{ openldap_ldap_pubkey_user }} notify: - restart_login_services - when: - name: Start rpcbind service ansible.builtin.service: diff --git a/tasks/ldap_client_debian.yml b/tasks/ldap_client_debian.yml index 866b677..ff4a907 100755 --- a/tasks/ldap_client_debian.yml +++ b/tasks/ldap_client_debian.yml @@ -1,9 +1,21 @@ --- -- name: Install the openldap client and required Packages for Ubuntu +- name: Wait for locks + ansible.builtin.include_tasks: + file: wait_for_locks.yml + +- name: Update APT Repos # noqa no-handler + ansible.builtin.apt: + update_cache: true + register: cache_updated + until: + - cache_updated is not failed + +- name: packages-debian | Install APT Packages ansible.builtin.apt: name: "{{ openldap_client_pkgs }}" state: present - update_cache: true + register: apt_install_result + until: apt_install_result is not failed - name: Install ssh-ldap-pubkey pip package ansible.builtin.include_tasks: diff --git a/tasks/ldap_client_redhat.yml b/tasks/ldap_client_redhat.yml index 1c9f39e..d57d2be 100755 --- a/tasks/ldap_client_redhat.yml +++ b/tasks/ldap_client_redhat.yml @@ -1,4 +1,8 @@ --- +- name: Wait for locks + ansible.builtin.include_tasks: + file: wait_for_locks.yml + - name: Install the openldap client and required Packages for RedHat ansible.builtin.dnf: name: "{{ openldap_client_pkgs }}" diff --git a/tasks/ldap_server_install.yml b/tasks/ldap_server_install.yml index 4a1275d..3936ab5 100755 --- a/tasks/ldap_server_install.yml +++ b/tasks/ldap_server_install.yml @@ -1,4 +1,8 @@ --- +- name: Wait for locks + ansible.builtin.include_tasks: + file: wait_for_locks.yml + - name: Install the openldap and required Packages for RedHat ansible.builtin.dnf: name: "{{ openldap_server_pkgs }}" diff --git a/tasks/main.yml b/tasks/main.yml index 1510308..c6a2da5 100755 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -7,8 +7,6 @@ - "{{ ansible_os_family }}.yml" tags: - always -- name: Set up - ansible.builtin.setup: {} - name: Add /etc/hosts entry for ldap server ansible.builtin.lineinfile: diff --git a/tasks/samba_server.yml b/tasks/samba_server.yml index e7a17fb..fb693b6 100644 --- a/tasks/samba_server.yml +++ b/tasks/samba_server.yml @@ -1,4 +1,8 @@ --- +- name: Wait for locks + ansible.builtin.include_tasks: + file: wait_for_locks.yml + - name: Install samba and required Packages for RedHat ansible.builtin.package: name: "{{ samba_pkgs }}" diff --git a/tasks/wait_for_locks.yml b/tasks/wait_for_locks.yml new file mode 100644 index 0000000..57419c9 --- /dev/null +++ b/tasks/wait_for_locks.yml @@ -0,0 +1,26 @@ +--- +- name: wait_for_locks | Wait or cloud-init to finish + community.general.cloud_init_data_facts: + filter: status + register: ciresult + until: + - ciresult.cloud_init_data_facts.status.v1.stage is defined + - not ciresult.cloud_init_data_facts.status.v1.stage + retries: 50 + delay: 10 + +- name: wait_for_locks | Wait for automatic system updates + ansible.builtin.shell: + cmd: fuser {{ item }} >/dev/null 2>&1 + loop: + - /var/lib/dpkg/lock + - /var/lib/dpkg/lock-frontend + - /var/lib/rpm/.rpm.lock + register: lockresult + until: + - lockresult.rc == 1 + changed_when: + - lockresult.rc == 0 + failed_when: false + retries: 50 + delay: 10