Feature users config ssh #9 #10
|
@ -6,8 +6,8 @@ retry_files_save_path = /tmp/
|
|||
inventory=./hosts
|
||||
host_key_checking=False
|
||||
gathering = smart
|
||||
#stdout_callback=unixy
|
||||
stdout_callback=debug
|
||||
stdout_callback=unixy
|
||||
#stdout_callback=debug
|
||||
|
||||
[privilege_escalation]
|
||||
become=True
|
||||
|
|
|
@ -5,28 +5,39 @@ user_groups:
|
|||
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.
|
||||
- name: mysecondgroup
|
||||
gid: 702
|
||||
state: absent
|
||||
- name: admin
|
||||
(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.
|
||||
gid: 703
|
||||
(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.
|
||||
|
||||
|
||||
users:
|
||||
- name: remember
|
||||
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.
|
||||
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.
|
||||
password: "blabla"
|
||||
groups:
|
||||
- mygroup
|
||||
- admin
|
||||
(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.
|
||||
uid: 1100
|
||||
enable_sudo: false
|
||||
(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
|
||||
bash_lines:
|
||||
- line: "testline"
|
||||
(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"
|
||||
(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
|
||||
- line: "export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh"
|
||||
state: present
|
||||
- line: "alias ls='ls lah'"
|
||||
state: present
|
||||
bash_blocks:
|
||||
(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.
|
||||
- content: |
|
||||
(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.
|
||||
#testing
|
||||
(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.
|
||||
#multiline
|
||||
(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: absent
|
||||
(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.
|
||||
ssh_config:
|
||||
- ServerAliveInterval: 10
|
||||
- name: test
|
||||
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.
|
||||
keys:
|
||||
- file: key2
|
||||
state: absent
|
||||
|
|
|||
(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.
|
|
@ -13,7 +13,7 @@
|
|||
group: "{{ item.item.name }}"
|
||||
mode: 0600
|
||||
state: touch
|
||||
when: item.stat.exists == False
|
||||
when: item.stat.exists == False and item.item.state == "present"
|
||||
with_items:
|
||||
- "{{ sshconfig.results }}"
|
||||
no_log: True
|
||||
|
@ -42,3 +42,4 @@
|
|||
- "{{ users }}"
|
||||
- ssh_config
|
||||
- skip_missing: true
|
||||
when: item.0.state == "present"
|
||||
|
|
|
@ -17,11 +17,15 @@ Ansible roles to create/configure users on Linux/FreeBSD.
|
|||
| password | string of an encrypted value(1) | string |
|
||||
| groups | additional groups the user should belong to | list |
|
||||
| uid | optionally specify a user id | int |
|
||||
| enable_sudo | Enable passwordless sudo for the given user | bool |
|
||||
| keys | list of dictionaries | list |
|
||||
| bash_lines | configure lines in .bashrc | list |
|
||||
| bash_blocks | configure lines in .bashrc | list |
|
||||
| csh_lines | configure lines in .cshrc | list |
|
||||
| csh__blocks | 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
|
||||
The default shells depending on the OS are:
|
||||
|
||||
|
@ -45,6 +49,7 @@ users:
|
|||
groups:
|
||||
- mygroup
|
||||
uid: 1100
|
||||
enable_sudo: true
|
||||
keys:
|
||||
- file: key1
|
||||
state: present
|
||||
|
@ -53,7 +58,13 @@ users:
|
|||
state: present
|
||||
- line: "alias ls='ls lah'"
|
||||
state: present
|
||||
bash_blocks:
|
||||
- content: |
|
||||
#testing
|
||||
#multiline
|
||||
state: present
|
||||
- name: test
|
||||
enable_sudo: false
|
||||
keys:
|
||||
- file: key2
|
||||
state: absent
|
||||
|
@ -95,6 +106,9 @@ This role allows you to add or remove lines to a user's `.bashrc` or `cshrc` fil
|
|||
|
||||
Add items to the **shell_lines** key in the **users** variable. Each item exists of a _line_ and _state_ key.
|
||||
|
||||
**lines**
|
||||
|
||||
Use _lines_ if you want to make sure a single line is present or not.
|
||||
Example:
|
||||
```
|
||||
shell_lines:
|
||||
|
@ -106,5 +120,16 @@ shell_lines:
|
|||
state: present
|
||||
```
|
||||
|
||||
**blocks**
|
||||
|
||||
use blocks if you want to make sure a number of lines that belong together are
|
||||
present or not.
|
||||
|
||||
Example:
|
||||
```
|
||||
bash_blocks:
|
||||
- content: |
|
||||
if [ condition ]; then
|
||||
do something
|
||||
state: present
|
||||
```
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
---
|
||||
- name: Check for required variables
|
||||
fail:
|
||||
msg: "Variable: 'users.name' or 'users.state' NOT defined!"
|
||||
with_items: "{{ users }}"
|
||||
when: item.state is not defined or item.name is not defined
|
||||
|
||||
|
||||
- include_tasks: set_facts.yml
|
||||
- include_tasks: users.yml
|
||||
- include_tasks: ssh_config.yml
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Set default shell
|
||||
- set_fact:
|
||||
default_shell: "{{ default_freebsd_shell }}"
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
@ -6,3 +7,20 @@
|
|||
default_shell: "{{ default_linux_shell }}"
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
# Set sudoers path
|
||||
- set_fact:
|
||||
sudoers_path: /usr/local/etc/sudoers.d
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- set_fact:
|
||||
sudoers_path: /etc/sudoers.d
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
# Set sudo config path
|
||||
- set_fact:
|
||||
sudo_config_path: /usr/local/etc/sudoers
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- set_fact:
|
||||
sudo_config_path: /etc/sudoers
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
- name: Ensure .ssh folder is created
|
||||
file:
|
||||
path: "/home/{{item.name}}/.ssh"
|
||||
|
@ -7,6 +8,7 @@
|
|||
group: "{{ item.name }}"
|
||||
with_items:
|
||||
- "{{ users }}"
|
||||
when: item.state == "present"
|
||||
|
||||
|
||||
- name: Configure authorized_keys
|
||||
|
@ -17,4 +19,5 @@
|
|||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- keys
|
||||
when: item.0.state is defined and item.0.state == "present"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
- name: Ensure groups exist
|
||||
- name: Add/Remove group
|
||||
group:
|
||||
name: "{{ item.name }}"
|
||||
gid: "{{ item.gid | default(omit) }}"
|
||||
|
@ -7,7 +7,7 @@
|
|||
with_items: "{{ user_groups }}"
|
||||
|
||||
|
||||
- name: Ensure users exist
|
||||
- name: Add/Remove user
|
||||
user:
|
||||
name: "{{ item.name }}"
|
||||
state: "{{ item.state | default('present') }}"
|
||||
|
@ -15,12 +15,12 @@
|
|||
groups: "{{ item.groups | default(omit) }}"
|
||||
uid: "{{ item.uid | default(omit) }}"
|
||||
shell: "{{ item.shell | default(default_shell) }}"
|
||||
append: yes
|
||||
no_log: True
|
||||
remove: yes
|
||||
no_log: False
|
||||
with_items: "{{ users }}"
|
||||
|
||||
|
||||
- name: Configure bashrc
|
||||
- name: Configure bashrc lines
|
||||
lineinfile:
|
||||
path: "/home/{{ item.0.name }}/.bashrc"
|
||||
line: "{{ item.1.line }}"
|
||||
|
@ -30,17 +30,84 @@
|
|||
- "{{ users }}"
|
||||
- bash_lines
|
||||
- skip_missing: true
|
||||
when: ansible_os_family == 'Debian'
|
||||
when: ansible_os_family == 'Debian' and item.0.state == "present"
|
||||
|
||||
- name: Configure bashrc blocks
|
||||
blockinfile:
|
||||
path: "/home/{{ item.0.name }}/.bashrc"
|
||||
content: "{{ item.1.content }}"
|
||||
marker: "# {mark} ANSIBLE managed content. Block item #{{ listitem }}"
|
||||
state: "{{ item.1.state | default('present') }}"
|
||||
backup: yes
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- bash_blocks
|
||||
- skip_missing: true
|
||||
when: ansible_os_family == 'Debian' and item.0.state == "present"
|
||||
loop_control:
|
||||
index_var: listitem
|
||||
|
||||
- name: Configure cshrc
|
||||
- name: Configure cshrc lines
|
||||
lineinfile:
|
||||
path: "/home/{{ item.0.name }}/.cshrc"
|
||||
line: "{{ item.1.line }}"
|
||||
state: "{{ item.1.state | default('present')}}"
|
||||
backup: yes
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- csh_lines
|
||||
- skip_missing: true
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
when: ansible_os_family == 'FreeBSD' and item.0.state == "present"
|
||||
|
||||
- name: Configure cshrc blocks
|
||||
blockinfile:
|
||||
path: "/home/{{ item.0.name }}/.cshrc"
|
||||
content: "{{ item.1.conent }}"
|
||||
marker: "# {mark} ANSIBLE managed content. Block item #{{ listitem }}"
|
||||
state: "{{ item.1.state | default('present')}}"
|
||||
backup: yes
|
||||
with_subelements:
|
||||
- "{{ users }}"
|
||||
- csh_blocks
|
||||
- skip_missing: true
|
||||
when: ansible_os_family == 'FreeBSD' and item.0.state == "present"
|
||||
loop_control:
|
||||
index_var: listitem
|
||||
|
||||
- name: Ensure sudo is installed (Debian)
|
||||
apt:
|
||||
name: sudo
|
||||
update_cache: yes
|
||||
cache_valid_time: "{{ apt_cache_valid | default('86400') }}"
|
||||
when: ansible_os_family == "Debian"
|
||||
|
||||
- name: Ensure sudo is installed (FreeBSD)
|
||||
portinstall:
|
||||
I'm going to try this with I'm going to try this with [`pkgng`](https://docs.ansible.com/ansible/2.6/modules/pkgng_module.html?highlight=pkg) I don't like to mix _ports_ in with my _pkg's_ if I can avoid it.
|
||||
name: sudo
|
||||
state: present
|
||||
when: ansible_os_family == "FreeBSD"
|
||||
|
||||
- name: Enable sudo for user
|
||||
lineinfile:
|
||||
path: "{{ sudoers_path }}/{{ item.name }}"
|
||||
line: "{{ item.name }} ALL=(ALL) NOPASSWD:ALL"
|
||||
state: present
|
||||
create: true
|
||||
when: item.enable_sudo is defined and item.enable_sudo == true
|
||||
with_items: "{{ users }}"
|
||||
|
||||
- name: Disable sudo for user
|
||||
file:
|
||||
path: "{{ sudoers_path }}/{{ item.name }}"
|
||||
state: absent
|
||||
when: item.enable_sudo is defined and item.enable_sudo == false
|
||||
with_items: "{{ users }}"
|
||||
|
||||
- name: Include sudoers.d
|
||||
lineinfile:
|
||||
dest: "{{ sudo_config_path }}"
|
||||
state: present
|
||||
regexp: '^\#includedir {{ sudoers_path }}'
|
||||
line: '#includedir {{ sudoers_path }}'
|
||||
validate: 'visudo -cf %s'
|
||||
|
||||
|
|
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.