Skip to content

Commit

Permalink
Merge pull request #607 from SquirrelCorporation/605-choreadd-elevati…
Browse files Browse the repository at this point in the history
…on-privilege-test-in-check-connection-playbook

[CHORE] Add sorting option and enhance Ansible playbook tasks
  • Loading branch information
SquirrelDeveloper authored Dec 28, 2024
2 parents f30dee1 + 07d186a commit df09a4e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@
- name: Check that you can connect (GET) to the API and it returns a status 200
ansible.builtin.uri:
url: "{{ _ssm_masterNodeUrl }}/api/ping"
- name: Test Sudo Working
hosts: all
tasks:
- become: true
command: id -u
register: id_output
- assert:
that: id_output.stdout == '0'
- name: Task completion summary
hosts: all
tasks:
- debug:
msg: "Become completed with {{ id_output.stdout }}"
2 changes: 1 addition & 1 deletion server/src/controllers/rest/logs/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const getTaskEvents = async (req, res) => {
if (!id) {
throw new NotFoundError('No id');
}
const events = await AnsibleLogsRepo.findAllByIdent(id);
const events = await AnsibleLogsRepo.findAllByIdent(id, 1);

new SuccessResponse('Get task logs successful', events).send(res);
};
6 changes: 3 additions & 3 deletions server/src/data/database/repository/AnsibleLogsRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ async function create(ansibleLog: AnsibleLog): Promise<AnsibleLog> {
return created.toObject();
}

async function findAllByIdent(ident: string): Promise<AnsibleLog[] | null> {
return await AnsibleLogModel.find({ ident: ident }).sort({ createdAt: -1 }).lean().exec();
async function findAllByIdent(ident: string, sortedBy: -1 | 1 = -1): Promise<AnsibleLog[] | null> {
return await AnsibleLogModel.find({ ident: { $eq: ident } }).sort({ createdAt: sortedBy }).lean().exec();
}

async function deleteAllByIdent(ident: string) {
return await AnsibleLogModel.deleteMany({ ident: ident }).lean().exec();
return await AnsibleLogModel.deleteMany({ ident: { $eq: ident } }).lean().exec();
}

async function deleteAll(): Promise<void> {
Expand Down

0 comments on commit df09a4e

Please sign in to comment.