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

(bugfix) [5.4.1.1] Task shouldn't fail if user in list doesn't exist #34

Merged
merged 1 commit into from
Feb 2, 2021

Conversation

jvleminc
Copy link
Collaborator

@jvleminc jvleminc commented Feb 2, 2021

If a user mentioned in the list list_of_os_users doesn't exist in the destination server for task 5.4.1.1, the task should not abort but simply continue with other users:

- name: 5.4.1.1 Ensure password expiration is 365 days or less\
    5.4.1.2 Ensure minimum days between password changes is configured\n
    5.4.1.3 Ensure password expiration warning days is 7 or more"
  block:
    - name: 5.4.1.1 Ensure password expiration is 365 days or less | PASS_MAX_DAYS
      lineinfile:
        state: present
        dest: /etc/login.defs
        regexp: "^PASS_MAX_DAYS"
        line: "PASS_MAX_DAYS {{ pass_expire_in_days }}"
    - name: 5.4.1.1 Ensure password expiration is 365 days or less | PASS_MIN_DAYS
      lineinfile:
        state: present
        dest: /etc/login.defs
        regexp: "^PASS_MIN_DAYS"
        line: "PASS_MIN_DAYS {{ pass_min_days }}"
    - name: 5.4.1.1 Ensure password expiration is 365 days or less | PASS_WARN_AGE
      lineinfile:
        state: present
        dest: /etc/login.defs
        regexp: "^PASS_WARN_AGE"
        line: "PASS_WARN_AGE {{ pass_warn_age }}"
    - name: 5.4.1.1 Ensure password expiration is 365 days or less | chage
      command: "chage --maxdays {{ pass_expire_in_days }} {{ item }}"
      with_items: "{{ list_of_os_users }}"
    - name: 5.4.1.1 Ensure password expiration is 365 days or less | chage --mindays
      command: "chage --mindays {{ pass_min_days }} {{ item }}"
      with_items: "{{ list_of_os_users }}"
    - name: 5.4.1.1 Ensure password expiration is 365 days or less | chage --warndays
      command: "chage --warndays {{ pass_warn_age }} {{ item }}"
      with_items: "{{ list_of_os_users }}"

@jvleminc jvleminc requested a review from alivx February 2, 2021 21:04
@alivx alivx merged commit 4047ef0 into master Feb 2, 2021
@jvleminc jvleminc deleted the bugfix/5.4.1.1_ignore_errors_when_user_not_exists branch February 3, 2021 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants