I’m looking for to do a test before to execute a task. I need to checkup if my computer has already joined the domain
before to join it. otherwise, the adcli will failed.
When computer isn’t in domain, the klist will return a “not found” message and at this time the “join active directory” must be running…
Something goes wrong because this task will not be runned.
Here’re the portion of task:
`
[…]
name: checking if domain already joined
shell: /bin/bash -c “/usr/bin/klist -k|grep -i {{ ansible_hostname }}”
register: ad_join_status
ignore_errors: true
I'm looking for to do a test before to execute a task. I need to checkup if my computer has already joined the domain
before to join it. otherwise, the adcli will failed.
When computer isn't in domain, the klist will return a "not found" message and at this time the "join active directory"
must be running...
Something goes wrong because this task will not be runned.
Here're the portion of task:
Otherwise, the klist cannot start because it doesn't found the file : /etc/krb5.keytab :
>
# /usr/bin/klist -k|grep -i server_name
klist:Keytable file '/etc/krb5.keytab'notfound whilestarting keytab
>
And in this case nothing appears in stdout:
>
ok:[localhost]=>
ad\_join\_status\.stdout:''
>
That's means, I should use an another test for checking domain joining...
Right, so far this isn't really Ansible related. Determine a command which reliably tells you
whether the domain is already joined *before* you are trying to automate it.