Skip to content

[RFE] Add chdir parm to the at module #13

Open
@benjdudas

Description

@benjdudas
SUMMARY

This RFE is to have a chdir parameter, similar to what's currently available for the shell module, added to the at module.

When using at with the ansible-pull and the --purge option the job will fail since the execution directory is being removed.

As a workaround, the at job can be scheduled using the shell module.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

at.py

ADDITIONAL INFORMATION

cmd:

ansible-pull -U https://github.com/benjdudas/ansible_pull.git -i hosts --purge

local.yml

---
- hosts: local
  connection: local
  gather_facts: false

  tasks:
    - name: run logger in 2 minutes
      at:
        command: /bin/logger 'AT task ran from Ansible'
        count: 2
        units: minutes
        unique: yes
      environment:
        PWD: /root

    - name: copy job file
      copy:
        src: ./myjob.txt
        dest: /root/myjob.txt

    - name: testing with shell mod, runs date in 2 min
      shell:
        chdir: /root
        cmd: at now + 2 min -f myjob.txt

    - name: cleanup job file
      file:
        path: /root/myjob.txt
        state: absent

...

mail logs:

From [email protected]  Tue Apr 14 11:59:00 2020
Return-Path: <[email protected]>
X-Original-To: vagrant
Delivered-To: [email protected]
Received: by rhel-awx.localdomain (Postfix, from userid 0)
        id 9F4431067836; Tue, 14 Apr 2020 11:59:00 -0400 (EDT)
Subject: Output from your job       36
To: [email protected]
Message-Id: <[email protected]>
Date: Tue, 14 Apr 2020 11:59:00 -0400 (EDT)
From: [email protected] (root)

sh: line 31: cd: /root/.ansible/pull/rhel-awx: No such file or directory
Execution directory inaccessible

From [email protected]  Tue Apr 14 12:00:00 2020
Return-Path: <[email protected]>
X-Original-To: vagrant
Delivered-To: [email protected]
Received: by rhel-awx.localdomain (Postfix, from userid 0)
        id CCF951067836; Tue, 14 Apr 2020 12:00:00 -0400 (EDT)
Subject: Output from your job       38
To: [email protected]
Message-Id: <[email protected]>
Date: Tue, 14 Apr 2020 12:00:00 -0400 (EDT)
From: [email protected] (root)

Tue Apr 14 12:00:00 EDT 2020

The first mail was from the at task (run logger in 2 minutes) showing "Execution directory inaccessible". The second mail log is from the shell task (testing with shell mod, runs date in 2 min) running /bin/date with at.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis issue/PR relates to a feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions