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

[BUG] Role fails with "AnsibleUndefinedVariable: 'dict object' has no attribute 'systemd'" #88

Closed
ProfessorSalty opened this issue Oct 25, 2020 · 3 comments
Assignees

Comments

@ProfessorSalty
Copy link

ProfessorSalty commented Oct 25, 2020

Sorry if I'm missing something obvious here but I'm new to Ansible. I'm running into an issue doing a dry run of this role.

Describe the bug
When running the role (with --check') on a new Ubuntu 20.04 VM in Proxmox, it fails on timesyncd.confwithAnsibleUndefinedVariable: 'dict object' has no attribute 'systemd'`.

To Reproduce
Build a brand new Ubuntu 20.04 VM and do a dry run (--check) of the role on it.

Expected behavior
To run without crashing.

System (lsb_release -a):

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal

Additional context

# playbook.yml
- name: 'Provision Image'
  hosts: all
  roles:
    - { 
      role: konstruktoid.hardening, 
      sshd_port: 56789
      }
  become: true
  remote_user: toor
@konstruktoid
Copy link
Owner

Hi @ProfessorSalty, thanks for reporting the issue. I'll have a look at it, but I assume it was meant to be opened in https://github.com/konstruktoid/ansible-role-hardening

@konstruktoid
Copy link
Owner

Since the --check doesn't actually change anything, the custom facts directories and files aren't created. This results in the ansible_local.systemd.version and related facts are missing.

~$ ls -l /etc/ansible/facts.d/systemd.fact
ls: cannot access '/etc/ansible/facts.d/systemd.fact': No such file or directory

The --check will also fail on anything that requires some kind of interaction:

fatal: [127.0.0.1]: FAILED! => {"msg": "The conditional check 'needrestart_directory.stat.exists and needrestart_restart_set.rc != 0' failed. The error was: error while evaluating conditional (needrestart_directory.stat.exists and needrestart_restart_set.rc != 0): 'dict object' has no attribute 'rc'\n\nThe error appears to be in '/private/etc/ansible/roles/konstruktoid.hardening/tasks/packages.yml': line 42, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: configure needrestart\n  ^ here\n"}

@ProfessorSalty
Copy link
Author

Ah, yes, I suppose this is the wrong repo. Sorry about that. I appreciate you taking your time out for the explanation - it looks like I can't just blindly check my tasks, so I'll have to modify my config to account for missing facts. Thanks so much!

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