Feature users config ssh #9 #10
|
@ -17,7 +17,7 @@ users:
|
|||
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
||||
keys:
|
||||
- file: key1
|
||||
state: present
|
||||
shell_lines:
|
||||
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
||||
bash_lines:
|
||||
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
||||
- line: "testline"
|
||||
state: present
|
||||
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
|
||||
|
@ -30,6 +30,6 @@ users:
|
|||
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
||||
keys:
|
||||
- file: key2
|
||||
state: absent
|
||||
shell_lines:
|
||||
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
||||
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
|
||||
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
||||
csh_lines:
|
||||
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
||||
- line: "alias ls ls -lah"
|
||||
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
||||
state: present
|
||||
|
|
|||
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
(Click to expand code)
`TASK [users : Ensure .ssh folder is created]` fails if user is set to `absent` after it was previously `present`.
<details>
<summary>(Click to expand code)</summary>
```yaml
TASK [users : Ensure .ssh folder is created] *******************************************************
failed: [127.0.0.1] (item={u'bash_lines': [{u'line': u'testline', u'state': u'present'}, {u'line': u'export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh', u'state': u'present'}, {u'line': u"alias ls='ls lah'", u'state': u'present'}], u'name': u'remember', u'keys': [{u'state': u'present', u'file': u'key1'}], u'ssh_config': [{u'ServerAliveInterval': 10}], u'state': u'absent', u'groups': [u'mygroup'], u'uid': 1100}) => {
"changed": false,
"gid": 1100,
"group": "1100",
"item": {
"bash_lines": [
{
"line": "testline",
"state": "present"
},
{
"line": "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh",
"state": "present"
},
{
"line": "alias ls='ls lah'",
"state": "present"
}
],
"groups": [
"mygroup"
],
"keys": [
{
"file": "key1",
"state": "present"
}
],
"name": "remember",
"ssh_config": [
{
"ServerAliveInterval": 10
}
],
"state": "absent",
"uid": 1100
},
"mode": "0700",
"owner": "1100",
"path": "/home/remember/.ssh",
"size": 4096,
"state": "directory",
"uid": 1100
}
MSG:
chown failed: failed to look up user remember
ok: [127.0.0.1] => (item={u'keys': [{u'state': u'absent', u'file': u'key2'}], u'name': u'test', u'csh_lines': [{u'line': u'alias ls ls -lah', u'state': u'present'}]})
PLAY RECAP *****************************************************************************************
127.0.0.1 : ok=8 changed=1 unreachable=0 failed=1
```
</details>
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone. I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group: If I add a user to a group: `admin`. I can't remove the user from a group. **Please advise** if there is a method I've over looked.
I can add but not remove, multiline bash entries.
I can add but not remove, multiline bash entries.
```yaml
users:
- name: remember
state: present
groups:
- mygroup
uid: 1100
keys:
- file: key1
state: present
bash_lines:
- line: "testline"
state: absent
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
state: present
- line: "alias ls='ls -lah'"
state: present
- line: |
#this is a testline
#this is a testline2
state: absent
ssh_config:
- ServerAliveInterval: 10
```
Please advise. **Please advise**.
We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime. We'll have to make the 'users.state' variable required. I'll make the necessary changes to the tasks and check for required variables at runtime.
the 'user' module ws using the 'append' option. This will be removed the 'user' module ws using the 'append' option. This will be removed
I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module. I updated the playbooks to add a task for multi line content leveraging the 'blockinfile' module.
I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here. I made the necessary changes and commited everything to @srgvg his repository so he can make a proper PR here.
|
|
@ -11,14 +11,15 @@ Ansible roles to create/configure users on Linux/FreeBSD.
|
|||
|
||||
| users | | |
|
||||
| ---: |---| ---|
|
||||
| _variable name_ | Description | Data type |
|
||||
| _variable name_ | Description | Data type |
|
||||
| name | username | string |
|
||||
| state | whether the user should be created or removed | present/absent |
|
||||
| password | string of an encrypted value(1) | string |
|
||||
| groups | additional groups the user should belong to | list |
|
||||
| uid | optionally specify a user id | int |
|
||||
| keys | list of dictionaries | list |
|
||||
| shell_lines | list of dictionaries | list |
|
||||
| bash_lines | configure lines in .bashrc | list |
|
||||
| csh_lines | configure lines in .cshrc | list |
|
||||
|
||||
(1) https://docs.ansible.com/ansible/latest/reference_appendices/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module
|
||||
## Default variables
|
||||
|
@ -47,7 +48,7 @@ users:
|
|||
keys:
|
||||
- file: key1
|
||||
state: present
|
||||
shell_lines:
|
||||
bash_lines:
|
||||
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
|
||||
state: present
|
||||
- line: "alias ls='ls lah'"
|
||||
|
@ -56,8 +57,8 @@ users:
|
|||
keys:
|
||||
- file: key2
|
||||
state: absent
|
||||
shell_lines:
|
||||
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
|
||||
csh_lines:
|
||||
- line: "ls ls -lah"
|
||||
state: absent
|
||||
```
|
||||
## Using the Role
|
||||
|
|
|
@ -1,4 +1,40 @@
|
|||
default_freebsd_shell: "/bin/csh"
|
||||
default_linux_shell: "/bin/bash"
|
||||
default_shell_lines:
|
||||
- SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh
|
||||
|
||||
|
||||
# Example variables
|
||||
#---
|
||||
#user_groups:
|
||||
# - name: mygroup
|
||||
# gid: 700
|
||||
# - name: mysecondgroup
|
||||
# gid: 702
|
||||
# state: absent
|
||||
#
|
||||
#
|
||||
#users:
|
||||
# - name: remember
|
||||
# state: present
|
||||
# password: "blabla"
|
||||
# groups:
|
||||
# - mygroup
|
||||
# uid: 1100
|
||||
# keys:
|
||||
# - file: key1
|
||||
# state: present
|
||||
# bash_lines:
|
||||
# - line: "testline"
|
||||
# state: present
|
||||
# - line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
|
||||
# state: present
|
||||
# - line: "alias ls='ls lah'"
|
||||
# state: present
|
||||
# ssh_config:
|
||||
# - ServerAliveInterval: 10
|
||||
# - name: test
|
||||
# keys:
|
||||
# - file: key2
|
||||
# state: absent
|
||||
# csh_lines:
|
||||
# - line: "alias ls ls -lah"
|
||||
# state: present
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
backup: yes
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- shell_lines
|
||||
- bash_lines
|
||||
- skip_missing: true
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
|||
state: "{{ item.1.state | default('present')}}"
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- shell_lines
|
||||
- csh_lines
|
||||
- skip_missing: true
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
|
|
TASK [users : Ensure .ssh folder is created]
fails if user is set toabsent
after it was previouslypresent
.(Click to expand code)
I guess the procedure I should use is. When a user is removed. Remove their variables so the script continues to function. Because the variables try to set because the home folder exists even though the user is gone.
If I add a user to a group:
admin
. I can't remove the user from a group. Please advise if there is a method I've over looked.I can add but not remove, multiline bash entries.
Please advise.