From 537d0df4fc04ac0ed6c5662cdffbf21bdb091c03 Mon Sep 17 00:00:00 2001 From: Nemo Date: Sun, 11 Oct 2020 13:26:29 +0200 Subject: [PATCH] Start working on workstation configuration --- .gitignore | 2 + playbook_workstation_configure.yml | 13 ++ roles/workstation_mutt/README.md | 36 +++++ roles/workstation_mutt/defaults/main.yml | 27 ++++ roles/workstation_mutt/meta/main.yml | 19 +++ roles/workstation_mutt/tasks/main.yml | 3 + roles/workstation_mutt/tasks/mutt.yml | 16 ++ roles/workstation_mutt/tasks/package.yml | 5 + roles/workstation_mutt/templates/mailcap.j2 | 4 + roles/workstation_mutt/templates/muttrc.j2 | 153 ++++++++++++++++++++ 10 files changed, 278 insertions(+) create mode 100644 playbook_workstation_configure.yml create mode 100644 roles/workstation_mutt/README.md create mode 100644 roles/workstation_mutt/defaults/main.yml create mode 100644 roles/workstation_mutt/meta/main.yml create mode 100644 roles/workstation_mutt/tasks/main.yml create mode 100644 roles/workstation_mutt/tasks/mutt.yml create mode 100644 roles/workstation_mutt/tasks/package.yml create mode 100644 roles/workstation_mutt/templates/mailcap.j2 create mode 100644 roles/workstation_mutt/templates/muttrc.j2 diff --git a/.gitignore b/.gitignore index ae34bbb..3bbd38b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ roles/powerdns.* inventory* !inventory_template/inventory.yml !inventory_template* +vars-workstation/vault-workstation.yml +vars-workstation/vars-workstation.yml diff --git a/playbook_workstation_configure.yml b/playbook_workstation_configure.yml new file mode 100644 index 0000000..6d22997 --- /dev/null +++ b/playbook_workstation_configure.yml @@ -0,0 +1,13 @@ +--- + +- hosts: localhost + vars_files: + - vars-workstation/vault-workstation.yml + - vars-workstation/vars-workstation.yml + roles: + - client_resolvers + - client_tools + - client_ntp + - client_iptables + - workstation_mutt + diff --git a/roles/workstation_mutt/README.md b/roles/workstation_mutt/README.md new file mode 100644 index 0000000..c8f7bd6 --- /dev/null +++ b/roles/workstation_mutt/README.md @@ -0,0 +1,36 @@ +Ansible Role: workstation mutt +========= + +This role configure Mutt on a GNU/Linux workstation. + +Requirements +------------ + +Mutt, gpg2 and abook installed. + +Role Variables +-------------- + +All variables and default values are defined in `defaults/main.yml`/ + +Dependencies +------------ + +None. + +Example Playbook +---------------- + + - hosts: localhost + roles: + - workstation_mutt + +License +------- + +BSD + +Author Information +------------------ + +This role was created in 2020 by Nemo. diff --git a/roles/workstation_mutt/defaults/main.yml b/roles/workstation_mutt/defaults/main.yml new file mode 100644 index 0000000..89b478a --- /dev/null +++ b/roles/workstation_mutt/defaults/main.yml @@ -0,0 +1,27 @@ +--- +# defaults file for workstation_mutt + +workstation_mutt_user: john +workstation_mutt_group: john +workstation_mutt_home: /home/john +workstation_mutt_realname: "John DOE" +workstation_mutt_spoolfile: "imaps://example.org:993/INBOX" +workstation_mutt_imap_user: "john" +workstation_mutt_imap_pass: "YOURSMTPPASSWORD" +workstation_mutt_smtp_url: "smtp://example.org:587/" +workstation_mutt_smtp_pass: "YOURSMTPPASSWORD" +workstation_mutt_from: "john@example.org" +workstation_mutt_trash: "imaps://example.org/Trash" +workstation_mutt_record: "+Sent" +workstation_mutt_postponed: "+Drafts" +workstation_mutt_folder: "imaps://example.org:993/" +workstation_mutt_pgp_sign_as: YOURPHPIDKEY +workstation_mutt_packages: + - gnupg + - mutt + - abook + - antiword + - pstotext + - poppler + - links + diff --git a/roles/workstation_mutt/meta/main.yml b/roles/workstation_mutt/meta/main.yml new file mode 100644 index 0000000..56e485d --- /dev/null +++ b/roles/workstation_mutt/meta/main.yml @@ -0,0 +1,19 @@ +galaxy_info: + author: nemo + description: Configure Mutt on a GNU/Linux workstation. + company: Wirebrass + + license: license (BSD) + + min_ansible_version: 2.4 + + platforms: + - name: Gentoo + versions: + - all + + galaxy_tags: + - mutt + - mail + +dependencies: [] diff --git a/roles/workstation_mutt/tasks/main.yml b/roles/workstation_mutt/tasks/main.yml new file mode 100644 index 0000000..ad46ee6 --- /dev/null +++ b/roles/workstation_mutt/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- import_tasks: package.yml +- import_tasks: mutt.yml diff --git a/roles/workstation_mutt/tasks/mutt.yml b/roles/workstation_mutt/tasks/mutt.yml new file mode 100644 index 0000000..b5dd870 --- /dev/null +++ b/roles/workstation_mutt/tasks/mutt.yml @@ -0,0 +1,16 @@ +--- +- name: Mailcap configured + template: + src: mailcap.j2 + dest: "{{ workstation_mutt_home }}/.mailcap" + owner: "{{ workstation_mutt_user }}" + group: "{{ workstation_mutt_group }}" + mode: 0600 + +- name: Mutt configured + template: + src: muttrc.j2 + dest: "{{ workstation_mutt_home }}/.muttrc" + owner: "{{ workstation_mutt_user }}" + group: "{{ workstation_mutt_group }}" + mode: 0600 diff --git a/roles/workstation_mutt/tasks/package.yml b/roles/workstation_mutt/tasks/package.yml new file mode 100644 index 0000000..01c3266 --- /dev/null +++ b/roles/workstation_mutt/tasks/package.yml @@ -0,0 +1,5 @@ +--- +- name: Mutt, abook, antiword, pstotext, gnupg and poppler installed + package: + name: "{{ workstation_mutt_packages }}" + state: present diff --git a/roles/workstation_mutt/templates/mailcap.j2 b/roles/workstation_mutt/templates/mailcap.j2 new file mode 100644 index 0000000..75be92f --- /dev/null +++ b/roles/workstation_mutt/templates/mailcap.j2 @@ -0,0 +1,4 @@ +text/html; links %s; nametemplate=%s.html +text/html; links -dump %s; nametemplate=%s.html; copiousoutput +application/msword; antiword '%s'; copiousoutput; description=Word Document; nametemplate=%s.doc +application/pdf; pdftotext '%s' -; copiousoutput; description=PDF Document; nametemplate=%s.pdf diff --git a/roles/workstation_mutt/templates/muttrc.j2 b/roles/workstation_mutt/templates/muttrc.j2 new file mode 100644 index 0000000..fa5074f --- /dev/null +++ b/roles/workstation_mutt/templates/muttrc.j2 @@ -0,0 +1,153 @@ +# jeu de caractères des messages envoyés +set send_charset="utf-8" +# si aucun jeu de caractères n'est indiqué pour les messages entrant, nous supposons qu'il s'agit de windows +set assumed_charset="iso-8859-1" + +# défiler d'une ligne au lieu d'une page +set menu_scroll=yes + +# créer un motif de recherche par défaut pour chercher dans , To, Cc et Subject +set simple_search="~f %s | ~C %s | ~s %s" + +# configuration de base +set realname="{{ workstation_mutt_realname }}" +set header_cache =~/.mutt/cache/headers +set certificate_file =~/.mutt/certificates +set message_cachedir =~/.mutt/cache/bodies + +# configuration imap +set spoolfile="{{ workstation_mutt_spoolfile }}" +set imap_user="{{ workstation_mutt_imap_user }}" +set imap_pass="{{ workstation_mutt_imap_pass }}" +set imap_passive="no" +set imap_check_subscribed="yes" +set imap_list_subscribed="yes" + +# configuration SMTP +set smtp_url="{{ workstation_mutt_smtp_url }}" +set smtp_pass="{{ workstation_mutt_smtp_pass }}" +set from="{{ workstation_mutt_from }}" +set use_envelope_from=yes # Pour que postfix ou sendmail ne change pas votre from + +# petit plus +set trash="{{ workstation_mutt_trash }}" +set record="{{ workstation_mutt_record }}" +set postponed="{{ workstation_mutt_postponed }}" +set folder="{{ workstation_mutt_folder }}" +set imap_check_subscribed=yes +set mail_check=120 +set timeout=300 +set imap_keepalive=300 +set signature='~/signature.txt' + +# locales FR pour les nom des jours et mois +#set locale="fr_FR" + +# Format de date +set date_format="%A %d %b %Y à %H:%M:%S (%Z)" + +# phrase d'intro pour réponse quotée +set attribution="Le %d, %n a écrit :" +set forward_format="[Fwd: %s]" +set forward_quote + +mailboxes ! +#Editeur +set edit_hdrs +auto_view text/html +set editor="vim -c 'set syntax=mail ft=mail enc=utf-8'" # indiquer ici votre éditeur de texte préféré. + +color attachment magenta default # attachments +color body brightred default "(ftp|http)://[^ ]+" # point out URLs +color body brightcyan default [-a-z_0-9.]+@[-a-z_0-9.]+ # e-mail addresses +color bold brightblue default # boldface text +color error brightwhite red # error messages +color hdrdefault magenta default # default color of message header +color header brightmagenta default ^(From): # From and Subject header +color header brightwhite default ^(Subject): # From and Subject header +color header brightwhite default ^(Date): # Date header +color header white default ^(In-Reply-To): +color indicator brightred default # indicator bar +color markers brightblue default # wrapped line markers (+) +color message brightblack green # status messages +color normal default default # default +color quoted yellow default # quoted text, 1st quote level +color quoted1 green default # quoted text, 2nd quote level +color quoted2 brightblue default # quoted text, 3rd quote level +color quoted3 blue default # quoted text, 4th quoet level +color search black yellow # matched search patterns in pager +color signature red default # the signature (after sigdashes) +color status default blue # status lines +color tilde brightblue default # ``~'' used to pad blank lines +color tree green default # thread tree in the index menu +color underline brightgreen default # underlined text + +set pager_index_lines=7 +set pager_stop +set mask=".*" # the default mask hides dotfiles and maildirs are dotfiles now. + +macro index c "?" "open a different folder" +macro pager c "?" "open a different folder" + +auto_view text/html +bind index G imap-fetch-mail +set timeout=30 + +# ne pas montrer tous les entêtes seulement quelques-uns * +ignore * +unignore From To Cc Bcc Date Subject +# et dans cet ordre +unhdr_order * +hdr_order From: To: Cc: Bcc: Date: Subject: + +# activate TLS if available on the server +set ssl_starttls=yes +# always use SSL when connecting to a server +set ssl_force_tls=yes +# Display download progress every 5K +set net_inc=5 + +# Cancel a message when subject is blank +set abort_nosubject=yes + +auto_view application/msword +auto_view application/pdf + +set query_command= "abook --mutt-query '%s'" +macro index,pager A "abook --add-email-quiet" "Ajouter l'expediteur dans abook" +bind editor complete-query + +# set up the sidebar, default not visible +set sidebar_visible=yes +set sidebar_width=20 +set sidebar_folder_indent=yes +set sidebar_short_path=yes + +bind index \CP sidebar-prev +bind index \CN sidebar-next +bind index \CO sidebar-open +bind pager \CP sidebar-prev +bind pager \CN sidebar-next +bind pager \CO sidebar-open +color sidebar_new yellow default +set mailcap_path=~/.mailcap +set sidebar_sort_method=alpha + +#set beep_new=yes +set crypt_replysign=yes +set crypt_replyencrypt=yes +set crypt_replysignencrypted=yes +set crypt_autosign=yes +set crypt_verify_sig=yes +set pgp_sign_as={{ workstation_mutt_pgp_sign_as }} +set pgp_decode_command="gpg2 %?p?--passphrase- 0? --no-verbose --batch --output - %f" +set pgp_verify_command="gpg2 --no-verbose --batch --output --verify %s %f" +set pgp_decrypt_command="gpg2 --passphrase- 0 --no-verbose --batch --output - %f" +set pgp_sign_command="gpg2 --no-verbose --batch --output --passphrase- 0 --armor --detach-sign --textmode %?a?-u %a? %f" +set pgp_autosign=yes +set pgp_replyencrypt=yes +set pgp_replysign=yes +set pgp_timeout=300 +set pgp_good_sign="^gpg: Signature correcte de " +set pgp_import_command="gpg2 --no-verbose --import %f" +