/ README.md
README.md
 1  # Description
 2  
 3  This role configures a [Launchd scheduled job](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/ScheduledJobs.html) for running a provided script or command.
 4  
 5  # Configuration
 6  
 7  ```yml
 8  launchd_timer_name: 'my-test'
 9  launchd_timer_description: 'Just a timer creation test.'
10  launchd_timer_user: 'root'
11  launchd_timer_frequency: '172800' # 48 hours
12  launchd_timer_timeout_sec: 120
13  launchd_timer_work_dir: '/tmp/somedir'
14  launchd_timer_environment:
15    MY_ENV_VAR: 'some_value'
16  launchd_timer_script_content: |
17    #!/usr/bin/env bash
18    echo "My Timer Script!"
19  ```
20  The `frequency` accepts seconds for `StartInterval`. There is no support for using `StartCalendarInterval` yet.
21  
22  ## Startup and Restarts
23  
24  Automatic restarts can be enabled using:
25  ```yml
26  launchd_timer_keep_alive: false
27  ```
28  You can also start the timer at boot or at creation time:
29  ```yml
30  launchd_timer_start_on_boot: true
31  launchd_timer_start_on_creation: true
32  ```
33  
34  ## Consul Metadata
35  
36  You can also customize the Consul service definition:
37  ```
38  launchd_timer_consul_service_id: 'my-test-abc'
39  launchd_timer_consul_service_name: 'my-test'
40  launchd_timer_consul_extra_tags: ['test', 'abc']
41  launchd_timer_consul_meta: { my_meta: 'metadata' }
42  ```
43  The service runs the [`check.sh`](templates/check.sh.j2) script to verify timer health..
44  
45  # Usage
46  
47  The the timer starts the service with configured frequency.
48  
49  The state of the timer can be checked in a limited capcity using `launchctl`:
50  ```
51   > sudo launchctl my-test
52  {
53  	"StandardOutPath" = "/var/log/my-test.out.log";
54  	"LimitLoadToSessionType" = "System";
55  	"StandardErrorPath" = "/var/log/my-test.err.log";
56  	"Label" = "my-test";
57  	"OnDemand" = false;
58  	"LastExitStatus" = 0;
59  	"Program" = "/usr/local/bin/my-test";
60  	"ProgramArguments" = ();
61  };
62  ```