Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict Local users login using SSH or from Console #2

Open
wants to merge 94 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
c6fa0af
feat(ad): Add support for Ubuntu
sylus Jun 19, 2018
b942a59
Rename to Linux AD and rename variables to use same linux_ad_ prefix
KAMI911 Jan 29, 2019
be538ad
Move home directory and user shell to variables
KAMI911 Jan 29, 2019
8346a6c
Try to figure out OS version automatically
KAMI911 Jan 29, 2019
9b1089d
Update meta information
KAMI911 Jan 29, 2019
46012fc
Update README file
KAMI911 Jan 29, 2019
f3aff0a
Fix import errors
KAMI911 Jan 29, 2019
b618260
Add a minimal playbook
KAMI911 Jan 29, 2019
2d185a6
Add a symlonk
KAMI911 Jan 29, 2019
6ed9883
Fix status page URLs
KAMI911 Jan 30, 2019
580752d
Fix status page URLs
KAMI911 Jan 30, 2019
c28dd1c
Avoid yum loop deprication warning
KAMI911 Jan 30, 2019
49c23ff
Introduce handling of non standard Linux home directory
KAMI911 Jan 31, 2019
f9d5eb0
Fix directory rights for newly created subhome directory
KAMI911 Jan 31, 2019
1662016
Fix directory rights for newly created subhome directory
KAMI911 Jan 31, 2019
63d66bd
Fix bad sssd.conf configuration options
KAMI911 Feb 6, 2019
fa4f82c
Add Ubuntu support
KAMI911 Jun 17, 2019
00dcf66
Change from ansible_lsb.major_release|int to ansible_distribution_maj…
KAMI911 Jun 17, 2019
489409d
Handle Ubuntu 18 and Debian 10
KAMI911 Jun 17, 2019
c20b578
Remove apt loop warning
KAMI911 Jun 17, 2019
dcc75d7
Remove bad sudoers file replacement
KAMI911 Jun 18, 2019
094257b
Add Debian 9 support file and small fixes fir Debian/Ubuntu
KAMI911 Jun 19, 2019
ff143fa
Move task files into sepatrated files
KAMI911 Jun 19, 2019
e21a5b0
Update Deabian 10 support file
KAMI911 Jun 19, 2019
bbb4f9e
Add sudoers.d file support and add a AD group to the sudoers.
KAMI911 Jun 19, 2019
e22d86d
Update license file
KAMI911 Jun 19, 2019
b77439e
Add sudoers file processing to tasks
KAMI911 Jun 19, 2019
b46d8f0
Add RedHat-6 support
KAMI911 Jul 2, 2019
718f173
Remove non existing package for RedHat 6
KAMI911 Jul 3, 2019
19ef8b9
Correct variable include on Debian/Ubuntu
KAMI911 Jul 3, 2019
1f715fe
Remove samba-common-tools package from Red Hat 6 requirements since t…
KAMI911 Jul 4, 2019
7c61905
Add krb5.conf.d direction creation in RedHat 6 based distributions
KAMI911 Jul 4, 2019
db97f00
Add krb5.conf.d direction creation in RedHat 6 based distributions
KAMI911 Jul 4, 2019
90e8874
Add krb5.conf.d direction creation in RedHat 6 based distributions
KAMI911 Jul 4, 2019
554e1e0
Merge branch 'RedHat-6'
KAMI911 Jul 4, 2019
f76157f
Remove uncommented code
KAMI911 Jul 5, 2019
0dd98f2
Make oddjobd the laste hook
KAMI911 Jul 9, 2019
2dae621
Fix variable name
KAMI911 Jul 9, 2019
3e7b9cd
Add more Ubuntu dependancy
KAMI911 Jul 9, 2019
c66b3c1
VIP|ubuntu_support: Add Ubuntu support
KAMI911 Jul 9, 2019
1ce5044
Use correct ansible_distribution variable name
KAMI911 Jul 9, 2019
247d59b
Add second round of Ubuntu and Debian Active Directory patches
KAMI911 Jul 10, 2019
6aacb1a
Fix file name typo
KAMI911 Jul 10, 2019
b786a25
Fix file name typo
KAMI911 Jul 10, 2019
1d8f4d2
Specify domain realm nam in Ubuntu Active Directory join
KAMI911 Jul 10, 2019
b3b4e7f
Add different method to joining to AD under Ubuntu
KAMI911 Jul 10, 2019
d342a7f
Add mkhomedir to common-session for Ubuntu
KAMI911 Jul 10, 2019
4e54b6d
Add mkhomedir to common-session for Ubuntu
KAMI911 Jul 10, 2019
1fc0da0
Remove unnecessary login to Domain in Ubuntu
KAMI911 Jul 10, 2019
c3b0f3a
Adjust meta info of role
KAMI911 Jul 10, 2019
d0a3dc1
Adjust meta info of role
KAMI911 Jul 10, 2019
4bb088a
Fix dbus service handling
KAMI911 Oct 1, 2019
eb488da
Try to restart oddjobd when domain home directory is created
KAMI911 Oct 29, 2019
6d36305
Implement AD rejoin via deleting /etc/krb5.keytab file if linux_ad_re…
KAMI911 Oct 29, 2019
ac4c808
Fix a typo in README
KAMI911 Oct 29, 2019
67dbc6a
Add additional tags
KAMI911 Oct 29, 2019
16ef0d6
Fix missing quotes
KAMI911 Oct 30, 2019
09f8c29
Add more information about AWX/submodule usage in the README file
KAMI911 Nov 28, 2019
7d91593
Add EL8 support for test
KAMI911 Jan 24, 2020
3e98a51
Update dates
KAMI911 Jan 31, 2020
58e4869
Update code to support EL 8 with authselect (instead of authconfig)
KAMI911 Jan 31, 2020
1fe5cd5
Fix authselect's path
KAMI911 Jan 31, 2020
0daf4b2
Fix authselect's configuration fuse path
KAMI911 Jan 31, 2020
ad3ea6d
Add a basic commit test for Travis CI
KAMI911 Feb 3, 2020
1c533ba
Add python3 package to EL8 installation process
KAMI911 Feb 3, 2020
6730d66
Fixes for the test
KAMI911 Feb 3, 2020
e5111fa
Change the name of the role in the tests
KAMI911 Feb 3, 2020
3659f94
Use Ubuntu 18.04 for Travis CI tests
KAMI911 Feb 3, 2020
f75bef8
Remove Python3 dependancy in EL8
KAMI911 Feb 3, 2020
27b6fc1
Diable apply tests
KAMI911 Feb 3, 2020
20ef6d2
Compare with casted integers
KAMI911 Feb 19, 2020
60db598
Do common.yml sooner
KAMI911 Nov 11, 2020
649656a
Add ad_gpo_ignore_unreadable = True option to sssd.conf
KAMI911 Nov 12, 2020
918e29c
Get more information from AD before join
KAMI911 Nov 12, 2020
c1aab90
Move to use realms instead of using adcli
KAMI911 Nov 12, 2020
20c5de6
Separate rejoin
KAMI911 Nov 12, 2020
2502969
More verbose realm join
KAMI911 Nov 12, 2020
fdc2432
Update configuration files later
KAMI911 Nov 12, 2020
6b52312
Avoid config check warning message:
KAMI911 Dec 16, 2020
f2ed7ad
Move common task before anything else
KAMI911 Dec 16, 2020
b78374e
Add check for sssd configuration
KAMI911 Dec 16, 2020
f1fc801
Add sssd-tools package install for sssd configuration test
KAMI911 Dec 16, 2020
e586db8
Fix keytab remove on rejoin
KAMI911 Dec 17, 2020
e0bf463
Move back file configuration
KAMI911 Dec 17, 2020
1f97ed8
Introduce possibility to use FQ user name
KAMI911 Dec 17, 2020
710d7f6
Add firewall related settings
KAMI911 Jan 6, 2021
68b79cb
Add manage firewall tasks
KAMI911 Jan 6, 2021
a7edc71
Add minimal smb.conf
KAMI911 Jan 6, 2021
dd310ea
Normalize hosts file entry
KAMI911 Jan 6, 2021
097e5e7
Add delete AD file for rejoin
KAMI911 Jan 6, 2021
07fce5c
Fix sssd config file
KAMI911 Jan 6, 2021
d5581e6
Reorder commands
KAMI911 Jan 7, 2021
015224b
Fix semicollons
KAMI911 Jan 7, 2021
adb388e
Always include vars when tags are specified
KAMI911 Oct 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
---
services: docker
dist: bionic
language: python
python: "3.6"

env:
# Defaults.
- distro: centos7
test_idempotence: false
# Use the new container infrastructure
sudo: true

script:
# Configure test script so we can run extra tests after playbook is run.
- export container_id=$(date +%s)
- export cleanup=false
# Install ansible
addons:
apt:
packages:
- python3-pip

install:
# Install ansible
- pip3 install ansible

# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/sylus/e5d6eb8852d649ae78477b2daf86e707/raw
- chmod +x ${PWD}/tests/test.sh
# Check ansible version
- ansible --version

# Run tests.
- ${PWD}/tests/test.sh
# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg

script:
# Basic role syntax check
- "ansible-playbook tests/test.yml -i tests/inventory --syntax-check"
# - "ansible-playbook -i tests/inventory tests/test.yml --connection=local --become-user root"
# - "ansible-playbook -i tests/inventory tests/test.yml --connection=local --become-user root | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)"

notifications:
slack:
secure: M+yCxKJqimIn8NeW0B9zZfjgLur6YnxqA5XoulSuuIwNHqkAR7d6EAsydwR8vEKTqVfKdOobMVmalOCcQOw6HSwnu49KYUAESYsL/yyvK/aHXM52y6XV1L6s+gtD6/eQo3VECR8xMAM2+GkzUGeaA2hWA13CwXo7aXcik0/q2KTJb1eTXDj1LYyjwPE6pmHcWsxE6bmGLTvaHDpWQpoSTD3tiJqvAIVNsSGm4HiZ0rlVS09hM+xU3OTVIfurYmWJI+Do1KceINrwDlbEZgsYGXLCg5Oah/DK5pAmKocF8BDNZx01AH3vqG2yQSoV4xpTF+NdfHh2XFY9If1Ugyv9xDAkLbCkMzhzh8UIvXNCWvWstKh6I8gnJPJGUst0FXk2clCx+ILl4wlMrdd0UcUA5GX6R6ELUfxfT//xVK5I5t0IbCqBB5Nl1bDf7ndeksYqlTxk4DoM6t5yGlhCRqNz5z1SxMe2wv4OQaIuuNsFVvQ9USPc7FKHKxQQBAOiT8b0QNuFm8U/nresytpZrMQ0vMnMA9iQz+xQvdKyVw1ZS2HPx05lWBv0CC3sDkPqXETohG7bC5hkSY4LPNNlqtu6oOtfmbCuDfbpjpzAm5NvtNcdMavAd/jtEfO7sSxAwW02wty4XilXk4INMOp+2z5W2vwkyMkpTsvsnm7Da6mPzMA=
webhooks: https://galaxy.ansible.com/api/v1/notifications/
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2018 William Hearn
Copyright (c) 2019-2020 Kálmán Szalai - KAMI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
234 changes: 229 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,232 @@
# Ansible role for Active Directory
# Ansible Role: Installs and configures Active Directory on Linux.

[![Build Status][travisci-badge]][travisci]
Travis status: [![Build Status](https://travis-ci.org/KAMI911/ansible-role-linux-ad.svg?branch=master)](https://travis-ci.org/KAMI911/ansible-role-linux-ad)
Code Climate status: [![Code Climate](https://codeclimate.com/github/KAMI911/ansible-role-linux-ad/badges/gpa.svg)](https://codeclimate.com/github/KAMI911/ansible-role-linux-ad)
Test Coverage status: [![Test Coverage](https://codeclimate.com/github/KAMI911/ansible-role-linux-ad/badges/coverage.svg)](https://codeclimate.com/github/KAMI911/ansible-role-linux-ad/coverage)

<!-- Links Referenced -->
## Table of Contents

[travisci]: https://travis-ci.org/govcloud/ansible-role-ad
[travisci-badge]: https://travis-ci.org/govcloud/ansible-role-ad.png?branch=master
1. [Requirements][Requirements]
2. [Installation][Installation]
3. [Role Variables][Role Variables]
4. [Dependencies][Dependencies]
5. [Example Playbook][Example Playbook]
6. [Licensing][Licensing]
7. [Author Information][Author Information]
8. [Support][Support]
9. [Contributing][Contributing]
10. [Donation][Donation]

## Requirements

None.

## Installation

ansible-galaxy install kami911.linux-ad

## Role Variables

Available variables are listed below, along with default values (see `defaults/main.yml`):


### Port, connection, and firewall related options

linux_ad_manage_firewalld: true

Role manages the firewalld settings of required ports.

### Debug settings

linux_ad_authconfig_debug_mode: false

Use authconfig debug mode.

linux_ad_authconfig_debug_level: 3

Set authconfig debug level.

linux_ad_authconfig_domain: 'cloud.department.ca'

### Genereal AD settings

Set authconfig (FQDN) domain name.

linux_ad_authconfig_realm: 'CLOUD.DEPARTMENT.CA'

Set authconfig realm name.

linux_ad_authconfig_computer_ou: 'ou=computers,dc=cloud,dc=department,dc=ca'

Set the Active Directory path to computers organization unit.

linux_ad_authconfig_windomain: 'EXAMPLECOM'

Set authconfig Windows domain name.

linux_ad_authconfig_sssd_user: 'admin'

Specify an already existing domain user that has 'add computer to domain' rights.

linux_ad_authconfig_sssd_pass: 'pass'

Specify the password of that domain user.

linux_ad_authconfig_access_groups: []

An array/list of groups that have access to the host.

linux_ad_authconfig_access_users: []

An array/list of users that have access to the host.

linux_ad_ansible_distribution_major_version: '{{ ansible_lsb.major_release|int }}'

Specify the main version of your Linux OS if something gets wrong and the version is not available.

linux_ad_ad_info_ad_server: 'dc1.department.ca'

linux_ad_ad_info_ad_backup_server: 'dc2.department.ca'

Specify the primary and a backup Active Directory login server.

linux_ad_rejoin: false

Try to rejoint to the Active Directory via deleting /etc/krb5.keytab file. Default is false.

linux_ad_home_dir: '/home/%d/%u'

Home directory of the user.
Additionally you can use these variables:
%u -login name
%U - UID number
%d - domain name
%f - fully qualified user name (user@domain))
%% - %.

linux_ad_shell: '/bin/bash'

Shell to use for freshly created users.

linux_ad_use_fq_username: true

Use fully qualified name for login name. When false you can login with username, when tru you can login with username@domain_name

linux_ad_home_dir_base:
- '/home/{{ linux_ad_authconfig_domain }}'

If you not using /home/%s as home directory, the script have to create all of required domains subdirectory (in this example case /home/cloud.department.ca/). Please list all possible domains here.

linux_ad_home_dir_user: 'root'

The user of the newly created subhome directory.

linux_ad_home_dir_group: 'root'

The group of the newly created subhome directory.

linux_ad_home_dir_mode: 755

The mode of the newly created subhome directory.

linux_ad_sudoers_d:
- file: linux_ad
host: ALL
runas: ALL
ugid: '%Enterprise\ Admins'
nopasswd: true
commands:
- 'ALL'

Create sudoers file with these parameters. The file is filename of the created file in sudoers.d.

## Dependencies

None.

## Example Playbook

- hosts: all
roles:
- linux-ad

## Licensing

The lactransformer application and documantations are licensed under the terms of
the MIT / BSD, you will find a copy of this license in the
[LICENSE](LICENSE) file included in the source package.

## Author Information

This role was created in 2019-2020 by Kálmán Szalai - KAMI based on work of William Hearn (https://github.com/govcloud/ansible-role-ad)

## Support

If you have any question, do not hesitate and drop me a line.
If you found a bug, or have a feature request, you can [fill an issue](https://github.com/KAMI911/ansible-role-linux-ad/issues).

### Using as a submudule of an AWX playbook

#### Add as a submodule

```
git submodule add --force [email protected]:KAMI911/ansible-role-linux-ad.git roles/linux-ad
```

#### Update as sumodule

Update only this submodule

```
git submodule update --remote roles/linux-ad/
```

Update all submodules:

```
git submodule foreach git pull origin master
```

## Contributing

There are many ways to contribute to ansible-role-linux-ad -- whether it be sending patches,
testing, reporting bugs, or reviewing and updating the documentation. Every
contribution is appreciated!

Please continue reading in the [contributing chapter](CONTRIBUTING.md).

### Fork me on Github

https://github.com/KAMI911/ansible-role-linux-ad

Add a new remote `upstream` with this repository as value.

```
git remote add upstream https://github.com/KAMI911/ansible-role-linux-ad.git
```

You can pull updates to your fork's master branch:

```
git fetch --all
git pull upstream HEAD
```

## Donation

If you find this useful, please consider a donation:

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RLQZ58B26XSLA)


<!-- TOC URLs -->
[Requirements]: #requirements
[Installation]: #installation
[Role Variables]: #role_variables
[Dependencies]: #dependencies
[Example Playbook]: #example_playbook
[Licensing]: #licensing
[Author Information]: #author_information
[Support]: #support
[Contributing]: #contributing
[Donation]: #donation
50 changes: 37 additions & 13 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
---
authconfig_debug_mode: false
authconfig_debug_level: 3
linux_ad_manage_firewalld: true

authconfig_domain: 'cloud.department.ca'
authconfig_realm: 'CLOUD.DEPARTMENT.CA'
authconfig_computer_ou: 'ou=computers,dc=cloud,dc=department,dc=ca'
linux_ad_authconfig_debug_mode: false
linux_ad_authconfig_debug_level: 3

#authconfig_windomain: "EXAMPLECOM"
linux_ad_authconfig_domain: 'cloud.department.ca'
linux_ad_authconfig_realm: 'CLOUD.DEPARTMENT.CA'
linux_ad_authconfig_computer_ou: 'ou=computers,dc=cloud,dc=department,dc=ca'

authconfig_sssd_user: 'admin'
authconfig_sssd_pass: 'pass'
linux_ad_authconfig_windomain: 'EXAMPLECOM'

linux_ad_authconfig_sssd_user: 'admin'
linux_ad_authconfig_sssd_pass: 'pass'

# An array/list of groups that have access to the host
authconfig_access_groups: []
linux_ad_authconfig_access_groups: []

# An array/list of users that have access to the host
authconfig_access_users: []
linux_ad_authconfig_access_users: []

# This variable sometimes does not get set and shouldn't be relied on.
ansible_distribution_major_version: ""
linux_ad_ansible_distribution_major_version: '{{ ansible_distribution_major_version|int }}'

linux_ad_ad_info_ad_server: 'dc1.department.ca'
linux_ad_ad_info_ad_backup_server: 'dc2.department.ca'

linux_ad_rejoin: false

# Home directory of the user. (You can use these variables: %u -login name, %U - UID number, %d - domain name, %f - fully qualified user name (user@domain))
linux_ad_home_dir: '/home/%d/%u'
linux_ad_shell: '/bin/bash'
linux_ad_use_fq_username: true

linux_ad_home_dir_base:
- '/home/{{ linux_ad_authconfig_domain }}'
linux_ad_home_dir_user: 'root'
linux_ad_home_dir_group: 'root'
linux_ad_home_dir_mode: 0755

ad_info_ad_server: dc1.department.ca
ad_info_ad_backup_server: dc2.department.ca
linux_ad_sudoers_d:
- file: linux_ad
host: ALL
runas: ALL
ugid: '%Enterprise\ Admins'
nopasswd: true
commands:
- 'ALL'
Loading