Re: [ansible-project] Set SELinux to permissive mode and reboot.

21 views
Skip to first unread message
Message has been deleted

Stefan Hornburg (Racke)

unread,
Sep 4, 2019, 9:51:33 AM9/4/19
to ansible...@googlegroups.com
On 9/4/19 3:46 PM, Keith Mills wrote:
> Hello All,
>
> I need to set SELinux to permissive mode and reboot. When I run my playbook I get an error.
>
> Playbook:
>
> |
> ---
> -name:SetSELinuxto permissive mode.
>   selinux:
>     policy:targeted
>     state:permissive
>   when:ansible_selinux_python_present|bool
> -name:Reboot
>   selinux:
>   when:reboot_required|bool
> |
>
> Error:
>
> |
> TASK [buildservers
> :Reboot]************************************************************************************************************************************************
> fatal:[abls15ex]:FAILED!=>{"msg":"The conditional check 'reboot_required|bool' failed. The error was: error while
> evaluating conditional (reboot_required|bool): 'reboot_required' is undefined\n\nThe error appears to be in
> '/home/jamekeit/ds9/roles/buildservers/tasks/selinux.yaml': line 7, column 3, but may\nbe elsewhere in the file
> depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  when:
> ansible_selinux_python_present|bool\n- name: Reboot\n  ^ here\n"}
>
> |
>
> Can anyone help?

Apparently the variable "reboot_required" is not defined. Either set a default value or try

reboot_required | default(false) | bool

Regards
Racke

>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7facd55b-c7b9-4290-af03-8139924eeb6e%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/7facd55b-c7b9-4290-af03-8139924eeb6e%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc
Message has been deleted
Message has been deleted

Zolvaring

unread,
Sep 4, 2019, 10:36:08 PM9/4/19
to Ansible Project
I'm almost positive you'd have to register the SELinux task return to get this to work, 'reboot_required' is not going to exist outside of that scope, I think what you would need is:

---
- name: Set SELinux to permissive mode.

  selinux
:
    policy
: targeted
    state
: permissive
  register: set_selinux
  
when: ansible_selinux_python_present|bool
- name: Reboot
  selinux
:
  
when: set_selinux.reboot_required|bool

The return values for the selinux module are documented here https://docs.ansible.com/ansible/latest/modules/selinux_module.html, and reboot_required is among them. Hope this helps.

On Wednesday, September 4, 2019 at 6:46:33 AM UTC-7, Keith Mills wrote:
Hello All,

I need to set SELinux to permissive mode and reboot. When I run my playbook I get an error.

Playbook:

---
- name: Set SELinux to permissive mode.

  selinux
:
    policy
: targeted
    state
: permissive
 
when: ansible_selinux_python_present|bool
- name: Reboot
  selinux
:
 
when: reboot_required|bool

Error:

TASK [buildservers : Reboot] ************************************************************************************************************************************************
fatal
: [abls15ex]: FAILED! => {"msg": "The conditional check 'reboot_required|bool' failed. The error was: error while evaluating conditional (reboot_required|bool): 'reboot_required' is undefined\n\nThe error appears to be in '/home/jamekeit/ds9/roles/buildservers/tasks/selinux.yaml': line 7, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  when: ansible_selinux_python_present|bool\n- name: Reboot\n  ^ here\n"}


Can anyone help?
Reply all
Reply to author
Forward
Message has been deleted
0 new messages