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

Error observed during remediation at step 1.7.1 Ensure message of the day is configured properly #77

Open
sharmaranupama opened this issue Mar 16, 2022 · 1 comment

Comments

@sharmaranupama
Copy link

sharmaranupama commented Mar 16, 2022

Hi @alivx ,

I am facing a issue during remediation step where in I am getting the below error in step 1.7.1 Ensure message of the day is configured properly. I am not able to identify where I need to configure inventory_dir and custom_motd_file_path.

> 1.7.4 Ensure permissions on /etc/motd are configured] *************************************************************
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: ['{{ custom_motd_file_path }}', 'files/templates/motd.j2']: {{ inventory_dir }}/custom_templates/motd_custom.txt: '**inventory_di**r**' is undefined**\n\nThe error appears to be in '/home/anupama/CIS-Ubuntu-20.04-Ansible/tasks/section_1_Initial_Setup.yaml': line 960, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n- block:\n  - name: \"1.7.1 Ensure message of the day is configured properly\\n\n    ^ here\nThis one looks easy to fix. It seems that there is a value started\nwith a quote, and the YAML parser is expecting to see the line ended\nwith the same kind of quote. For instance:\n\n    when: \"ok\" in result.stdout\n\nCould be written as:\n\n   when: '\"ok\" in result.stdout'\n\nOr equivalently:\n\n   when: \"'ok' in result.stdout\"\n"}

The folder structure is as advised on github

-run.yaml
-CIS-Ubuntu-20.04-Ansible

configuration of run.yaml

- name: Harden Server
  hosts: localhost  
  become: yes
  remote_user: root
  gather_facts: yes  
  roles:
     - CIS-Ubuntu-20.04-Ansible  

Thank you!

@Sebastian-RG
Copy link
Contributor

Hi, the inventory_dir variable is a Special Variable

The directory of the inventory source in which the inventory_hostname was first defined

Apparently it has issues when the target is localhost.
You could try the workaround mentioned in the issue i linked

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

No branches or pull requests

2 participants