hashicorp / hashicorp/nomad

template: perms parameter not applied to directories

Open
#17,637 2 comments 0 reactions 0 assignees View on GitHub
stage/needs-discussion theme/template type/enhancement
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version
Nomad v1.5.6
BuildDate 2023-05-19T18:26:13Z
Revision 8af70885c02ab921dedbdf6bc406a1e886866f80

### Operating system and Environment details
Ubuntu 20.04.6 LTS (Focal Fossa)

### Issue
Directories created by `template` block doesn't respect the `perms` parameter

### Reproduction steps

Create `template` block with nested directories and set `perms` parameter

```
locals {
configs = [
"telegraf.conf",
"telegraf.d/mqtt-1.conf",
"telegraf.d/mqtt-2.conf",
"telegraf.d/mqtt-3.conf",
]
}

<......>

dynamic "template" {
for_each = local.configs
content {
change_mode = "signal"
change_signal = "SIGHUP"
data = file("./local/${template.value}")
destination = "local/${template.value}"
perms = "777"
}

```

#### Expected Result
Directory structure inherit the `perms` parameter

#### Actual Result
`perms` applied to files only. Permissions for `telegraf.d` is still `drwxr-xr-x`

```
# ls -la
total 16
drwxrwxrwx 3 nobody nogroup 4096 Jun 21 14:49 .
drwxr-xr-x 1 root root 4096 Jun 21 14:49 ..
-rwxrwxrwx 1 root root 3324 Jun 21 14:49 telegraf.conf
drwxr-xr-x 2 root root 4096 Jun 21 14:49 telegraf.d

root@f6279641233b:/local# ls -la telegraf.d/
drwxr-xr-x 2 root root 4096 Jun 21 14:49 .
drwxrwxrwx 3 nobody nogroup 4096 Jun 21 14:49 ..
-rwxrwxrwx 1 root root 649 Jun 21 14:49 mqtt-1.conf
-rwxrwxrwx 1 root root 590 Jun 21 14:49 mqtt-2.conf
-rwxrwxrwx 1 root root 637 Jun 21 14:49 mqtt-3.conf
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Trace Nomad's template block handling for nested destination paths and compare how perms are applied to files versus directories. Reproduce the example on Ubuntu, add a regression test for directory permissions, and consider the issue done when generated directories receive the configured perms without changing existing file behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.