: $ sudo apt install wireguard systemd-resolved unattended-upgrades \
: _ chrony isc-dhcp-server bind9 apache2 postfix \
-: _ dovecot-imapd fetchmail expect rsync gnupg
+: _ dovecot-imapd fetchmail rsync gnupg
Manual installation of Postfix prompted for configuration type and
mail name. The answers given are listed here.
apt: pkg=unattended-upgrades
#+END_SRC
-** Install Expect
-
-The ~expect~ program is used by [[* The Institute Commands][The Institute Commands]] to interact
-with Nextcloud on the command line.
-
-#+CAPTION: [[file:roles_t/core/tasks/main.yml][=roles_t/core/tasks/main.yml=]]
-#+BEGIN_SRC conf :tangle roles_t/core/tasks/main.yml
-
-- name: Install expect.
- become: yes
- apt: pkg=expect
-#+END_SRC
-
** Configure User Accounts
User accounts are created immediately so that backups can begin
#+CAPTION: [[file:playbooks/nextcloud-new.yml][=playbooks/nextcloud-new.yml=]]
#+BEGIN_SRC conf :tangle playbooks/nextcloud-new.yml
- hosts: core
- no_log: yes
tasks:
- name: Run occ user:add.
- shell: |
- spawn sudo -u www-data /usr/bin/php occ user:add {{ user }}
- expect {
- "Enter password:" {}
- timeout { exit 1 }
- }
- send "{{ pass|quote }}\n";
- expect {
- "Confirm password:" {}
- timeout { exit 2 }
- }
- send "{{ pass|quote }}\n";
- expect {
- "The user \"{{ user }}\" was created successfully" {}
- timeout { exit 3 }
- }
- args:
+ become: yes
+ shell:
chdir: /var/www/nextcloud/
- executable: /usr/bin/expect
+ cmd: >
+ sudo -u www-data sh -c
+ "OC_PASS={{ pass }}
+ php occ user:add {{ user }} --password-from-env"
#+END_SRC
** The Pass Command
}
#+END_SRC
-And here is the playbook that interacts with Nextcloud's ~occ
-users:resetpassword~ command using ~expect(1)~.
+And here is the playbook that runs Nextcloud's ~occ
+users:resetpassword~ command.
#+CAPTION: [[file:playbooks/nextcloud-pass.yml][=playbooks/nextcloud-pass.yml=]]
#+BEGIN_SRC conf :tangle playbooks/nextcloud-pass.yml
no_log: yes
tasks:
- name: Run occ user:resetpassword.
- shell: |
- spawn sudo -u www-data \
- /usr/bin/php occ user:resetpassword {{ user }}
- expect {
- "Enter a new password:" {}
- timeout { exit 1 }
- }
- send "{{ pass|quote }}\n"
- expect {
- "Confirm the new password:" {}
- timeout { exit 2 }
- }
- send "{{ pass|quote }}\n"
- expect {
- "Successfully reset password for {{ user }}" {}
- "Please choose a different password." { exit 3 }
- timeout { exit 4 }
- }
- args:
+ become: yes
+ become_user: www-data
+ shell:
chdir: /var/www/nextcloud/
- executable: /usr/bin/expect
+ cmd: >
+ OC_PASS={{ pass }}
+ php occ user:resetpassword {{ user }} --password-from-env
#+END_SRC
*** Installing the Less Aggressive passwd
- hosts: core
tasks:
- name: Run occ user:disable.
- shell: |
- spawn sudo -u www-data /usr/bin/php occ user:disable {{ user }}
- expect {
- "The specified user is disabled" {}
- timeout { exit 1 }
- }
- args:
+ become: yes
+ become_user: www-data
+ shell:
chdir: /var/www/nextcloud/
- executable: /usr/bin/expect
+ cmd: php occ user:disable {{ user }}
#+END_SRC
** The Client Command
sudo apt install wireguard systemd-resolved unattended-upgrades \
chrony isc-dhcp-server bind9 apache2 postfix \
- dovecot-imapd fetchmail expect rsync gnupg \
+ dovecot-imapd fetchmail rsync gnupg \
mariadb-server php php-{apcu,bcmath,curl,gd,gmp}\
php-{json,mysql,mbstring,intl,imagick,xml,zip} \
libapache2-mod-php \
no_log: yes
tasks:
- name: Run occ user:resetpassword.
- shell: |
- spawn sudo -u www-data \
- /usr/bin/php occ user:resetpassword {{ user }}
- expect {
- "Enter a new password:" {}
- timeout { exit 1 }
- }
- send "{{ pass|quote }}\n"
- expect {
- "Confirm the new password:" {}
- timeout { exit 2 }
- }
- send "{{ pass|quote }}\n"
- expect {
- "Successfully reset password for {{ user }}" {}
- "Please choose a different password." { exit 3 }
- timeout { exit 4 }
- }
- args:
+ become: yes
+ become_user: www-data
+ shell:
chdir: /var/www/nextcloud/
- executable: /usr/bin/expect
+ cmd: >
+ OC_PASS={{ pass }}
+ php occ user:resetpassword {{ user }} --password-from-env