-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
UnixPB: Add latest commit SHA to ansible.log file #2751
Conversation
Log entries now look like this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks ok but we really need to remove the duplication in the implementations.
Can we get this stored in the normal log location on the machine and remove the duplication as mentioned in #2746 (comment)
Log path is now |
Failing on the alpine build. A bit strange since when I was testing it on a mac and linux machine, ansible's working directory was always inside the repo. Investigating |
It might be because the alpine job copies the infra repo into the image and runs the playbook that way
Im guessing this copy command doesnt copy the .git folder. The macos build does not have this problem, presumably because it clones infra repo instead of copying it |
The centos 6 build fails aswell, again because it copies the infra repo into the image instead of git cloning. Need to think of a fix for this use case |
I think the vpc clones the repo and runs it on the boxes, instead of copying into the boxes and running it locally, so I think the vpc will not hit this error |
I've added a debug message to see where ansible's working directory is on the local host. Should provide insight |
Adding
|
@sxa ping for review |
Some thoughts regarding options here:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess it is easier to copy one level up, drawback is it could be slower and need more disk space.
it is better to get the SHA and pass as env to "docker build" then either add as a new instruction in dockerfile to dump it directly to ansible.log or pass in to ansible-playbook -e
but in this case, need to handle for both GH action and PVC run
ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/logs/tasks/main.yml
Outdated
Show resolved
Hide resolved
I was thinking of this, I think it is best for this particular use case |
I'm comfortable using this solution for the vpc machines, #2751 (comment), since those machines get deleted after the playbook run |
Still was not able to get the commit SHA despite grabbing the top level directory of the repo,
I've added some debug tasks to get a better idea of the ls output of the /infrastructure and /infrastructure/ansible directories |
It seems to kick it off from the top level directory of the repo, from the way it calls
|
Latest commit attempts to pass the SHA into the dockerfile using the github workflows standard variable If this doesnt work, I think I have to pass it into the dockerfile from the build.yml, but lets see |
dont you need pass GITHUB_SHA to the "docker build" first? |
Yeah I've done that with the latest commit. Though I did read some docs saying that it could be accessed straight from the dockerfile wihtout needing to be passed but who knows |
Still getting I must not be reading the docs correctly 😅 |
Ayyy the SHA got passed in properly |
Looks good |
The linter's acting up again
|
ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adopt_etc/tasks/main.yml
Show resolved
Hide resolved
Logs now look like this
Tested (and works) on linux, solaris and macos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thanks for doing these last changes :-)
ref #2745
Adds the latest commit SHA to the logs stored on the remote machine in the jenkins directory. Thankfully, the default working directory of ansible seems to be the directory of the playbook, in this case the
main.yml
file. Which meansgit rev-parse HEAD
will always be run in the correct directory.Tested from my workstation and https://awx2.adoptopenjdk.net/#/jobs/playbook/485?job_search=page_size:20;order_by:-finished;not__launch_type:sync (includes debug tasks which I have removed)