infrastructure icon indicating copy to clipboard operation
infrastructure copied to clipboard

Ansible request for logging when the playbooks are executed

Open sxa opened this issue 3 years ago • 2 comments

Please put the name of the software product (and affected platforms if relevant) in the title of this issue

  • [x] Missing install
  • [ ] Bug in ansible playbook
  • [ ] Request for new playbook addition

Details: I had a go at this once before and didn't quite manage to make it work, so it needs revisiting. It would be useful to record the last time that the ansible playbooks were run on a particular machine but logging it to e.g. /var/log/ansible.log A couple of lines in the log like:

202106031057 : Ansible playbook started
202106031203 : Ansible playbook completed

Would allow us to know

  1. When the playbooks were last run
  2. Whether they were successful (based on the presence or absence of the completed message) This should be tagged as adoptopenjdk Bonus points if we can include the SHA of the infrastructure repository used during the deployment and any list of explicit included/excluded tags.

sxa avatar Jun 03 '21 09:06 sxa

I have found that by default ansible logs to the remote host's syslog. If I run a playbook onto a remote host:

hkhel-mac:playbooks hkhel$ ansible-playbook -u root -i hosts AdoptOpenJDK_Unix_Playbook/main.yml -t "debug" -v

On the remote host's /var/log/syslog file I find

Mar  9 14:54:01 test-ibmcloud-ubuntu1604-x64-1 systemd[1]: Started Session 131518 of user root.
Mar  9 14:54:04 test-ibmcloud-ubuntu1604-x64-1 ansible-ansible.legacy.setup: Invoked with filter=[] gather_subset=['all'] fact_path=/etc/ansible/facts.d gather_timeout=10

You can tell ansible to save logs on the controller node by placing this variable in the ansible.cfg file:

log_path=/path/to/log

Which saves the ansible-playbook stdout to a file. Ideally I would want these same logs to be saved to a file on the remote host after execution

Haroon-Khel avatar Mar 09 '22 14:03 Haroon-Khel

Closing #2709 to cover all issues in here:

At the moment we have some provisional code that should do the first of these, but it is not working properly and does not create the log files. We should try and get a fix for that as a first pass, then look at the others.

Ideally this should include:

  • Start time
  • Completion times (if it finishes - the absence of a finish time should indicate failure of some sort)
  • Ideally which SHA of the infrastructure repository was used for the deployment.

See also https://ci.adoptopenjdk.net/view/Tooling/job/VagrantPlaybookCheck/1518/OS=Ubuntu2004,label=vagrant/consoleFull for a verbose debug run with some extra options

sxa avatar Sep 01 '22 09:09 sxa

@Haroon-Khel Is this complete on all platforms now?

sxa avatar Dec 01 '22 17:12 sxa

Windows: https://github.com/adoptium/infrastructure/pull/2848 UNIX: https://github.com/adoptium/infrastructure/pull/2746 AIX: https://github.com/adoptium/infrastructure/pull/2918

sxa avatar Feb 06 '23 11:02 sxa

This is complete once https://github.com/adoptium/infrastructure/pull/2918 gets merged

Haroon-Khel avatar Feb 17 '23 11:02 Haroon-Khel

2918 is merged - closing

sxa avatar Feb 24 '23 13:02 sxa