I'm using command:
sudo certbot --apache-ctl /opt/lampp/bin/apachectl
to install the certificate in XAMPP server. However the certificate is installing in the /etc/apache2 location.
How can I repoint to the XAMPP Apache server? The logs is below:
ubuntu#ip-172-31-33-70:~$ sudo certbot --apache-ctl /opt/lampp/bin/apachectl
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
No names were found in your configuration files. Please enter in your domain
name(s) (comma and/or space separated) (Enter 'c' to cancel): ploshop.co.in
Cert not yet due for renewal
You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/ploshop.co.in.conf)
What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Renewing an existing certificate
Created an SSL vhost at /etc/apache2/sites-available/000-default-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/000-default-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/000-default-le-ssl.conf
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting vhost in /etc/apache2/sites-enabled/000-default.conf to ssl vhost in /etc/apache2/sites-available/000-default-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Your existing certificate has been successfully renewed, and the new certificate
has been installed.
The new certificate covers the following domains: https://ploshop.co.in
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=ploshop.co.in
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/ploshop.co.in/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/ploshop.co.in/privkey.pem
Your cert will expire on 2021-11-17. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
ubuntu#ip-172-31-33-70:~$
Modify the locations based upon your installation. I am using the default paths.
Edit the file
Linux: /opt/lampp/apache/conf/extra/httpd-ssl.conf
Windows: /xampp/apache/conf/extra/httpd-ssl.conf
Locate the section that defines the port 443 listener:
Change this part:
<VirtualHost *:443>
...
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
To:
<VirtualHost *:443>
...
SSLEngine on
SSLCertificateFile "/etc/letsencrypt/live/ploshop.co.in/fullchain.pem"
SSLCertificateKeyFile "/etc/letsencrypt/live/ploshop.co.in/privkey.pem"
Do not forget to restart apache.
I know how to install ssl certificate using command-line. But i need a shell script this time to do this task.
Generally while doing this manually i first execute the fowllowing:-
sudo apt-get install certbot python-certbot-nginx
By executing the above i will be asked to continue or not?[Y/n]. I will enter 'Y'.Then i will execute the following command
sudo certbot --nginx
Executing the above will ask me to answer the following steps in ordered way:
Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel).
Agreement to Terms and Service [ (A)gree/(C)ancel: A ]
Consent to share development news and campaigns to my email address. [(Y)es/(N)o: N]
Which names would i like to activate HTTPS for? [Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): blank]
Redirection from http to https [Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 ]
After doing all this steps https will be enabled. Now i need to do these things done programatically by shell file.I have figured out to install certbot and python-certbot-nginx using this
sudo apt-get install certbot python-certbot-nginx -y
But i do not know how to proceed further as i have never worked with shell scripts
PS: I am providing a sample result when i execute sudo certbot --nginx and enter details by myself.
sudo certbot --nginx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): mygmailid#gmail.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: example.com
2: www.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
http-01 challenge for www.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/demowebsite.conf
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/demowebsite.conf
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/demowebsite.conf
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/demowebsite.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled
https://example.com and
https://www.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
https://www.ssllabs.com/ssltest/analyze.html?d=www.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
Your cert will expire on 2020-01-28. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
Though i am very late here but finally i did
as suggested by #JohnHanley in the comments. I went through the documentation and here is what i needed to execute the above mentioned steps in the question by command line.
run Obtain & install a certificate in your current webserver
-n Run without ever asking for user input. This may
require additional command line flags; the client will
try to explain which ones are required if it finds one
missing (default: False)
--nginx Obtain and install certificates using Nginx (default:False)
-d Domain names to apply. For multiple domains you can
use multiple -d flags or enter a comma separated list
of domains as a parameter. The first domain provided
will be the subject CN of the certificate, and all
domains will be Subject Alternative Names on the
certificate. The first domain will also be used in
some software user interfaces and as the file paths
for the certificate and related material unless
otherwise specified or you already have a certificate
with the same name. In the case of a name collision it
will append a number like 0001 to the file path name.
-m Email used for registration and recovery contact. Use
comma to register multiple emails, ex:
u1#example.com,u2#example.com. (default: Ask).
--redirect Automatically redirect all HTTP traffic to HTTPS for
the newly authenticated vhost. (default: Ask)
--agree-tos Agree to the ACME server's Subscriber Agreement
So the final command that i executed is below
certbot run -n --nginx --agree-tos -d example.com,www.example.com -m mygmailid#gmail.com --redirect
Here is the part of YAMLcode that i am trying to run on a node which has operating system, Centos-7......
file hierarchy is
--> roles/install_tools/tasks/main.yml
its not working fine, YAML syntax is also valid and correct !
Could someone help me ?
---
- name: install the Development tools package group
yum:
name: "#Development tools"
state: present
- name: Install common software requirements
ignore_errors: yes
become: true
yum: pkg={{ item }} state=present
with_items:
- yum-plugin-fastestmirror
- epel-release
- git
- libyaml-devel
- libnet-devel
- libnetfilter_queue-devel
- libpcap-devel
- pcre-devel
- file-devel
- jansson-devel
- nss-devel
- libcap-ng-devel
- lua-devel
- binutils
- gmp
- gmp-devel
- make
- ld
- glibc.i686
- python-pip
- perl-Sys-Syslog
- readline-devel
- ncurses-devel
- openssl-devel
- easy-rsa
- flex
- bison
- pcre
- zlib
- zlib-devel
- libpcap
- libdnet
- libdnet-devel
- m4
- gcc
- mysql-devel
- python-devel
- geoip
- geoip-devel
- libffi-devel
- vim
- lsof
- wget
- mlocate
- htop
- net-tools
- traceroute
- tcpdump
- radiusclient-ng.x86_64
- gmp-devel
- iptables-services
- dnsmasq
- pptpd
- mariadb-devel
- lzo-devel.x86_64
- crontabs
- gcc
- make
- rpm-build
- autoconf.noarch
- zlib-devel
- pam-devel
- openssl-devel
The error it is showing is;
TASK [install_tools : Install common software requirements] ***********************
failed: [meracentos] (item=[u'yum-plugin-fastestmirror', u'epel-release', u'git', u'libyaml-devel', u'libnet-devel', u'libnetfilter_queue-devel', u'libpcap-devel', u'pcre-devel', u'file-devel', u'jansson-devel', u'nss-devel', u'libcap-ng-devel', u'lua-devel', u'binutils', u'gmp', u'gmp-devel', u'make', u'ld', u'glibc.i686', u'python-pip', u'perl-Sys-Syslog', u'readline-devel', u'ncurses-devel', u'openssl-devel', u'easy-rsa', u'flex', u'bison', u'pcre', u'zlib', u'zlib-devel', u'libpcap', u'libdnet', u'libdnet-devel', u'm4', u'gcc', u'mysql-devel', u'python-devel', u'geoip', u'geoip-devel', u'libffi-devel', u'vim', u'lsof', u'wget', u'mlocate', u'htop', u'net-tools', u'traceroute', u'tcpdump', u'radiusclient-ng.x86_64', u'gmp-devel', u'iptables-services', u'dnsmasq', u'pptpd', u'mariadb-devel', u'lzo-devel.x86_64', u'crontabs', u'gcc', u'make', u'rpm-build', u'autoconf.noarch', u'zlib-devel', u'pam-devel', u'openssl-devel']) => {"changed": false, "failed": true, "item": ["yum-plugin-fastestmirror", "epel-release", "git", "libyaml-devel", "libnet-devel", "libnetfilter_queue-devel", "libpcap-devel", "pcre-devel", "file-devel", "jansson-devel", "nss-devel", "libcap-ng-devel", "lua-devel", "binutils", "gmp", "gmp-devel", "make", "ld", "glibc.i686", "python-pip", "perl-Sys-Syslog", "readline-devel", "ncurses-devel", "openssl-devel", "easy-rsa", "flex", "bison", "pcre", "zlib", "zlib-devel", "libpcap", "libdnet", "libdnet-devel", "m4", "gcc", "mysql-devel", "python-devel", "geoip", "geoip-devel", "libffi-devel", "vim", "lsof", "wget", "mlocate", "htop", "net-tools", "traceroute", "tcpdump", "radiusclient-ng.x86_64", "gmp-devel", "iptables-services", "dnsmasq", "pptpd", "mariadb-devel", "lzo-devel.x86_64", "crontabs", "gcc", "make", "rpm-build", "autoconf.noarch", "zlib-devel", "pam-devel", "openssl-devel"], "msg": "No package matching 'ld' found available, installed or updated", "rc": 126, "results": ["yum-plugin-fastestmirror-1.1.31-40.el7.noarch providing yum-plugin-fastestmirror is already installed", "git-1.8.3.1-6.el7_2.1.x86_64 providing git is already installed", "binutils-2.25.1-22.base.el7.x86_64 providing binutils is already installed", "gmp-1:6.0.0-12.el7_1.x86_64 providing gmp is already installed", "make-1:3.82-23.el7.x86_64 providing make is already installed", "No package matching 'ld' found available, installed or updated"]}
Use of with_items with the ansible yum is now deprecated. You should pass a list to name: as follows;
- name: Install common software requirements
become: true
yum:
state: present
name:
- yum-plugin-fastestmirror
- epel-release
- git
- libyaml-devel
- libnet-devel
- libnetfilter_queue-devel
- libpcap-devel
- pcre-devel
- file-devel
- jansson-devel
- nss-devel
- libcap-ng-devel
- lua-devel
- binutils
- gmp
- gmp-devel
- make
- ld
- glibc.i686
- python-pip
- perl-Sys-Syslog
- readline-devel
- ncurses-devel
- openssl-devel
- easy-rsa
The previous solution will give you the following error:
Invoking "yum" only once while using a loop via squash_actions is deprecated. Instead of using a loop to supply multiple items and specifying `name: {{ item }}`,
Below code worked for me -->
File - yumInstall.yml
---
- hosts: localhost
gather_facts: False
serial: 1
tasks:
- name: 1. Install Apache Packages
yum: name={{ item }} state=present
with_items:
- httpd
- yum-plugin-fastestmirror
- epel-release
- git
- libyaml-devel
- libnet-devel
- libnetfilter_queue-devel
- libpcap-devel
- pcre-devel
- file-devel
- jansson-devel
- nss-devel
- libcap-ng-devel
- lua-devel
- binutils
- gmp
- gmp-devel
- make
# - ld
- glibc.i686
- python-pip
- perl-Sys-Syslog
- readline-devel
- ncurses-devel
- openssl-devel
- easy-rsa
- flex
- bison
- pcre
- zlib
- zlib-devel
Executing playbook:-
ansible-playbook -i hosts yumInstall.yml
[WARNING]: Found both group and host with same name: localhost
PLAY [localhost] *****************************************************************************************************************************************************************
TASK [1. Install Apache Packages] ************************************************************************************************************************************************
changed: [localhost] => (item=[u'httpd', u'yum-plugin-fastestmirror', u'epel-release', u'git', u'libyaml-devel', u'libnet-devel', u'libnetfilter_queue-devel', u'libpcap-devel', u'pcre-devel', u'file-devel', u'jansson-devel', u'nss-devel', u'libcap-ng-devel', u'lua-devel', u'binutils', u'gmp', u'gmp-devel', u'make', u'glibc.i686', u'python-pip', u'perl-Sys-Syslog', u'readline-devel', u'ncurses-devel', u'openssl-devel', u'easy-rsa', u'flex', u'bison', u'pcre', u'zlib', u'zlib-devel'])
PLAY RECAP ***********************************************************************************************************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0
You can use simple list:
- name: Ensure useful util libs are present
yum:
name: ['httpie', 'the_silver_searcher', 'fasd', 'multitail', 'vim']
state: present
become: True
or as yaml list
- name: Ensure useful util libs are present
yum:
name:
- httpie
- the_silver_searcher
- fasd
- multitail
- vim
state: present
become: True
there is two errors in your config.
yum syntax error
with_items is deprecated now.
example:
- name: Install Tools
yum:
state: present
name:
- telnet
- htop
For the first time I am trying to use Ansible . When I tried to run a playbook I got this error:
ERROR! this task 'apt_repository' has extra params, which is only allowed in the following modules: command, shell, script, include, include_vars, add_host, group_by, set_fact, raw, meta
The error appears to have been in '/home/prism/Desktop/ansible/basic_package/main.yml': line 9, column 5, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: "Add Webupd8 ppa for youtube-dl"
^ here
main.yml :
---
- hosts: all
remote_user: root
tasks:
- name: "Upgrade the whole system"
apt: upgrade=dist update_cache=yes
- name: "Add Webupd8 ppa for youtube-dl"
apt_repository: repo ='ppa:nilarimogard/webupd8'
- name: "Install basic package"
apt: name={{ item }} state=installed
with_items:
- libffi-dev
- vnstat
- youtube-dl
- finger
- htop
- python3-dev
- axel
- curl
- fail2ban
- python-dev
- sendmail
- git
- python-software-properties
- software-properties-common
- python-pip
- nethogs
- unzip
- nmap
Looks like you have an extra space after repo parameter in the apt_repository task. Use the below code:
apt_repository: repo='ppa:nilarimogard/webupd8'